classmethod

Namespace: IronPython
We found 10 examples in language CSharp for this search. You will see 42 fragments of code.

Other methods

        [Fact]
        public void ClassMethod()
        {
            var c1 = new C1Builder(this.Session).Build();

            var classMethod = c1.ClassMethod();

            Assert.Equal("C1CustomC1Core", classMethod.Value);
        }

        [Fact]
        public void CallMethodTwice()
        {
            var c1 = new C1Builder(this.Session)
                .Build();

            var classMethod = c1.ClassMethod();

            var exceptionThrown = false;
            try
            {
                classMethod.Execute();
            }
            catch
            {
                exceptionThrown = true;
            }

            Assert.True(exceptionThrown);
        }

		[NativeEntry(NativeEntryType.ClassMethod)]
		public static int Add( VMachine phoVM )
		{
			var phoClassIns = phoVM.DataStack.GetNativeInstance<Photon.Array>(0);
			
			var v = phoVM.DataStack.GetValue(1);
			
			phoClassIns.Add( v );

			
			return 0;
		}
		
		[NativeEntry(NativeEntryType.ClassMethod)]
		public static int Remove( VMachine phoVM )
		{
			var phoClassIns = phoVM.DataStack.GetNativeInstance<Photon.Array>(0);
			
			var v = phoVM.DataStack.GetValue(1);
			
			phoClassIns.Remove( v );

			
			return 0;
		}
		
		[NativeEntry(NativeEntryType.ClassMethod)]
		public static int RemoveAt( VMachine phoVM )
		{
			var phoClassIns = phoVM.DataStack.GetNativeInstance<Photon.Array>(0);
			
			var index = phoVM.DataStack.GetInteger32(1);
			
			phoClassIns.RemoveAt( index );

			
			return 0;
		}
		
		[NativeEntry(NativeEntryType.ClassMethod)]
		public static int TryGet( VMachine phoVM )
		{
			var phoClassIns = phoVM.DataStack.GetNativeInstance<Photon.Array>(0);
			
			var index = phoVM.DataStack.GetInteger32(1);
			
			Value v = default(Value);
			var phoRetArg = phoClassIns.TryGet( index, out v );

			phoVM.DataStack.PushValue( v );
			phoVM.DataStack.PushBool( phoRetArg );
			
			return 2;
		}
		
		[NativeEntry(NativeEntryType.ClassMethod)]
		public static int TrySet( VMachine phoVM )
		{
			var phoClassIns = phoVM.DataStack.GetNativeInstance<Photon.Array>(0);
			
			var index = phoVM.DataStack.GetInteger32(1);
			var v = phoVM.DataStack.GetValue(2);
			
			var phoRetArg = phoClassIns.TrySet( index, v );

			phoVM.DataStack.PushBool( phoRetArg );
			
			return 1;
		}
		
		[NativeEntry(NativeEntryType.ClassMethod)]
		public static int Get( VMachine phoVM )
		{
			var phoClassIns = phoVM.DataStack.GetNativeInstance<Photon.Array>(0);
			
			var index = phoVM.DataStack.GetInteger32(1);
			
			var phoRetArg = phoClassIns.Get( index );

			phoVM.DataStack.PushValue( phoRetArg );
			
			return 1;
		}


        [TestInitialize]
        public void TestInitialize()
            => TestEnvironmentImpl.TestInitialize($"{TestContext.FullyQualifiedTestClassName}.{TestContext.TestName}");

        [TestCleanup]
        public void Cleanup() => TestEnvironmentImpl.TestCleanup();

        [TestMethod, Priority(0)]
        public async Task FirstArgumentClassMethodNotCls() {
            const string code = @"
class Test:
    @classmethod
    def test(x, y, z):
        pass
";
            var analysis = await GetAnalysisAsync(code);
            analysis.Diagnostics.Should().HaveCount(1);

            var diagnostic = analysis.Diagnostics.ElementAt(0);
            diagnostic.ErrorCode.Should().Be(ErrorCodes.NoClsArgument);
            diagnostic.SourceSpan.Should().Be(4, 14, 4, 15);
            diagnostic.Message.Should().Be(Resources.NoClsArgument.FormatInvariant("test"));
        }

        [TestMethod, Priority(0)]
        public async Task AbstractClassMethodNeedsClsFirstArg() {
            const string code = @"
from abc import abstractmethod

class A:
    @classmethod
    @abstractmethod
    def test(self, x):
        pass
";
            var analysis = await GetAnalysisAsync(code);
            analysis.Diagnostics.Should().HaveCount(1);

            var diagnostic = analysis.Diagnostics.ElementAt(0);
            diagnostic.ErrorCode.Should().Be(ErrorCodes.NoClsArgument);
            diagnostic.SourceSpan.Should().Be(7, 14, 7, 18);
            diagnostic.Message.Should().Be(Resources.NoClsArgument.FormatInvariant("test"));
        }

        [TestMethod, Priority(0)]
        public async Task AbstractClassMethod() {
            const string code = @"
from typing import abstractclassmethod
class A:
    @abstractclassmethod
    def test(cls):
        pass
";
            var analysis = await GetAnalysisAsync(code);
            analysis.Diagnostics.Should().BeEmpty();
        }

        [TestMethod, Priority(0)]
        public async Task ClsMethodValidInMetaclass() {
            const string code = @"
class A(type):
    def x(cls): pass

class B(A):
    def y(cls): pass

class MyClass(metaclass=B):
    pass

MyClass.x()
MyClass.y()
";
            var analysis = await GetAnalysisAsync(code);
            analysis.Diagnostics.Should().BeEmpty();
        }


		#region ISerializable Members

		public void GetObjectData(SerializationInfo info, StreamingContext context)
		{
			info.AddValue("mName", mName);

			info.AddValue("mDataType", mDataType);
		}

		#endregion

		#region IXmlSerializable Members

		public void WriteXml(System.Xml.XmlWriter writer)
		{
			writer.WriteStartElement("ClassMethod");
			writer.WriteElementString("Name",mName);
			writer.WriteElementString("DataType",mDataType);
			writer.WriteEndElement();
		}

		public System.Xml.Schema.XmlSchema GetSchema()
		{
			// TODO:  Add ClassPropertyCollection.GetSchema implementation
			return null;
		}

		public void ReadXml(System.Xml.XmlReader reader)
		{
			// TODO:  Add ClassPropertyCollection.ReadXml implementation
		}


        private void GetMethodType(FunctionDefinition node, out bool classmethod, out bool staticmethod) {
            classmethod = false;
            staticmethod = false;

            if (node.IsLambda) {
                staticmethod = true;
                return;
            }

            var classmethodObj = _scope.Interpreter.GetBuiltinType(BuiltinTypeId.ClassMethod);
            var staticmethodObj = _scope.Interpreter.GetBuiltinType(BuiltinTypeId.StaticMethod);
            foreach (var d in (_target.Decorators?.DecoratorsInternal).MaybeEnumerate()) {
                var m = _scope.GetValueFromExpression(d);
                if (m == classmethodObj) {
                    classmethod = true;
                } else if (m == staticmethodObj) {
                    staticmethod = true;
                }
            }
        }

        public void Walk() {
            IMember self = null;
            bool classmethod, staticmethod;
            GetMethodType(_target, out classmethod, out staticmethod);
            if (!staticmethod) {
                self = _scope.LookupNameInScopes("__class__", NameLookupContext.LookupOptions.Local);
                if (!classmethod) {
                    var cls = self as IPythonType;
                    if (cls == null) {
                        self = null;
                    } else {
                        self = new AstPythonConstant(cls, ((cls as ILocatedMember)?.Locations).MaybeEnumerate().ToArray());
                    }
                }
            }

            if (_target.ReturnAnnotation != null) {
                var retAnn = new TypeAnnotation(_scope.Ast.LanguageVersion, _target.ReturnAnnotation);
                var m = retAnn.GetValue(new AstTypeAnnotationConverter(_scope));
                if (m is IPythonMultipleMembers mm) {
                    _returnTypes.AddRange(mm.Members.OfType<IPythonType>());
                } else if (m is IPythonType type) {
                    _returnTypes.Add(type);
                }
            }

            _scope.PushScope();
            if (self != null) {
                var p0 = _target.ParametersInternal?.FirstOrDefault();
                if (p0 != null && !string.IsNullOrEmpty(p0.Name)) {
                    _scope.SetInScope(p0.Name, self);
                }
            }
            _target.Walk(this);
            _scope.PopScope();
        }

        public override bool Walk(FunctionDefinition node) {
            if (node != _target) {
                // Do not walk nested functions (yet)
                return false;
            }

            if (_overload.Documentation == null) {
                var docNode = (node.Body as SuiteStatement)?.Statements.FirstOrDefault();
                var ce = (docNode as ExpressionStatement)?.Expression as ConstantExpression;
                var doc = ce?.Value as string;
                if (doc != null) {
                    _overload.SetDocumentation(doc);
                }
            }

            return true;
        }

        public override bool Walk(ExpressionStatement node) {
            return base.Walk(node);
        }

        public override bool Walk(ReturnStatement node) {
            foreach (var type in _scope.GetTypesFromValue(_scope.GetValueFromExpression(node.Expression))) {
                _returnTypes.Add(type);
            }

            return false;
        }

        public string StealFieldInfo(string nameOfClass, params string[] requestedFields)
        {
            Type type = Type.GetType(nameOfClass);
  

            FieldInfo[] classFields = type.GetFields
                (BindingFlags.NonPublic|BindingFlags.Instance|
                BindingFlags.Static|BindingFlags.Public);
            StringBuilder sb = new StringBuilder();

             Object classInstance = Activator.CreateInstance
                (type, new object[] { });

            sb.AppendLine($"Class under investigation: {type}");

            foreach (var field in classFields)
            {
               if(requestedFields.Contains(field.Name))
                {
                    sb.AppendLine($"{field.Name} = {field.GetValue(classInstance)}");
                }
            }
            return sb.ToString().TrimEnd();
        }

        public string CollectGettersAndSetters(string className)
        {
            Type classType = Type.GetType(className);

            MethodInfo[] methods = classType.GetMethods
                (BindingFlags.Public | BindingFlags.NonPublic |
                BindingFlags.Instance | BindingFlags.Static);
            StringBuilder sb = new StringBuilder();

            foreach (var classMethod in methods)
            {
                if(classMethod.Name.StartsWith("get"))
                {
                    sb.AppendLine
                        ($"{classMethod.Name} will return {classMethod.ReturnType}");
                }
            }
            foreach (var classMethod in methods)
            {
                if(classMethod.Name.StartsWith("set"))
                { 
                    sb.AppendLine
                       ($"{classMethod.Name} will set field of {classMethod.GetParameters().First().ParameterType}");
                }
            }
            return sb.ToString().Trim();
        }

//-----------------------------------------------------------------------------
// Torque
// Copyright GarageGames, LLC 2012
//-----------------------------------------------------------------------------

/// <ClassName>AnimationSet</ClassName>
/// <summary>
/// <para>An AnimationSet is actually a ScriptObject which acts as a 
/// container for dynamic fields related to Animation Set information. This will
/// only work if the ScriptObject is given the class of "AnimationSet"</para>
/// <para></para>
/// </summary>
/// <example> 
/// This sample shows how to create an AnimationSet by hand when you know what
/// the animation names and datablocks will be:
/// <code>
/// new ScriptObject(OrcAnimationSet)
/// {
///    northWalkAnimation = "orcNorthWalk";
///    southWalkAnimation = "orcSouthWalk";
///    eastWalkAnimation = "orcEastWalk";
///    westWalkAnimation = "orcWestWalk";
///    class = "AnimationSet";
/// };
/// </code>
/// If you only know the name of the set, you can dynamically create the fields and their values:
/// <code>
/// new ScriptObject(OrcAnimationSet){ class = "AnimationSet" };
/// OrcAnimationSet.AddAnimation("northWalkAnimation", "orcNorthWalk");
/// OrcAnimationSet.AddAnimation("eastWalkAnimation", "orcEastWalk");
/// OrcAnimationSet.AddAnimation("southWalkAnimation", "orcSouthWalk");
/// </code>
/// You can mix the above two examples together when you have a pre-defined set of animation names,
/// but you do not know the field values yet:
/// <code>
/// new ScriptObject(OrcAnimationSet)
/// {
///    northWalkAnimation = "";
///    southWalkAnimation = "";
///    eastWalkAnimation = "";
///    westWalkAnimation = "";
///    class = "AnimationSet";
/// };
/// OrcAnimationSet.ChangeDatablock("northWalkAnimation", "orcNorthWalk");
/// OrcAnimationSet.ChangeDatablock("southWalkAnimation", "orcSouthWalk");
/// OrcAnimationSet.ChangeDatablock("eastWalkAnimation", "orcEastWalk");
/// OrcAnimationSet.ChangeDatablock("westWalkAnimation", "orcWestWalk");
/// </code>
/// </example>
/// <seealso cref="ScriptObject"/>

/// <ClassMethod>AnimationSet</ClassMethod>
/// <summary>Returns the number of animations in the set</summary>
/// <returns>Numeric value of how many dynamic animation fields in ScriptObject</returns>
/// <example>
/// This example shows how to print out the number of animations in this set to the console:
/// <code>
/// %animationCount = OrcAnimationSet.GetAnimationCount();
/// echo("The Orc Animation Set contains" SPC %animationCount SPC "animations.");
/// </code>
/// </example>
function AnimationSet::GetAnimationCount(%this)
{
   //return %this.getDynamicFieldCount();
   error("% - Not implemented");
   return 0;
}

/// <ClassMethod>AnimationSet::AddAnimation</ClassMethod>
/// <summary>
/// Adds a new animation field and corresponding datablock to the set </summary>
/// <param name="name">Name of the new animation field.</param>
/// <param name="animationDatablock">The AnimationAsset assigned to the new animation field</param>
/// <returns>True if the animation was successfully added. False if the field already existed or the animationDatablock is invalid</returns>
/// <example>
/// This example shows how to add a new animation and its value to a set. 
/// <code>OrcAnimationSet.AddAnimation("westWalkAnimation", "orcWestWalk");</code>
/// </example>
function AnimationSet::AddAnimation(%this, %name, %animationDatablock)
{
   if(%name $= "")
   {
      error("% - Invalid name specified for AnimationSet::AddAnimation");
      return false;
   }
   
   if(!isObject(%animationDatablock))
   {
      error("% - Invalid animation datablock specified for AnimationSet::AddAnimation");
      return false;
   }
   
   %this.setFieldValue(%name, %animationDatablock);
   
   return true;
}

/// <ClassMethod>AnimationSet::RemoveAnimation</ClassMethod>
/// <summary>
/// Deletes an animation field from the set. Note: Currently not implemented.
/// </summary>
/// <param name="parameterName">Parameter description</param>
/// <returns>Returns true if the animation was successfully removed. False if the animation did not exist</returns>
/// <example>
/// This example shows how to remove a specific animation from a set
/// <code>OrcAnimationSet.RemoveAnimation("westWalkAnimation");</code>
/// </example>
function AnimationSet::RemoveAnimation(%this, %name)
{
   error("% - Not implemented");
   return true;
}

/// <ClassMethod>AnimationSet::ChangeDatablock</ClassMethod>
/// <summary>
/// Changes the animation datablock on the specified field
/// </summary>
/// <param name="name">The animation field to modify</param>
/// <param name="animationDatablock">The new animation datablock</param>
/// <returns>Returns true if the change was successful. False if the animation does not exist or the animationDatablock is invalid</returns>
/// <example>
/// This example shows how to change the animation datablock for a specific animation in a set
/// <code>OrcAnimationSet.ChangeDatablock("westWalkAnimation", "orcWestWalk");</code>
/// </example>
function AnimationSet::ChangeDatablock(%this, %name, %animationDatablock)
{
   if(!isObject(%animationDatablock))
   {
      error("% - Invalid animation datablock specified for AnimationSet::ChangeDatablock");
      return false;
   }
   
   %fieldCount = %this.getDynamicFieldCount();
   
   for(%i = 0; %i < %fieldCount; %i++)
   {
      %currentField = %this.getDynamicField(%i);
      
      if(%currentField $= %name)
      {
         %this.setFieldValue(%name, %animationDatablock);
         return true;
      }
   }

/// <ClassMethod>AnimationSet::GetAnimationDatablock</ClassMethod>
/// <summary>
/// Accessor for the animation datablock on the specified animation field
/// </summary>
/// <param name="name">The name of the animation field</param>
/// <returns>Returns a AnimationAsset attached to the specified name. "" Will be returned if the specified name is invalid</returns>
/// <example>
/// This example shows how to get the AnimationAsset of a specific animation and print it to the console.
/// <code>
/// %animationDatablock = OrcAnimationSet.GetAnimationDatablock("westWalkAnimation");
/// echo("The Orc's west walk animation is " SPC %animationDatablock.getName());
/// </code>
/// </example>
function AnimationSet::GetAnimationDatablock(%this, %name)
{
   %animationDatablock = %this.getFieldValue(%name);
   
   if(%animationDatablock $= "")
      warn("% - Warning: Returning a null animation datablock in AnimationSet::GetAnimationDatablock");
   
   return %animationDatablock;
}

//-----------------------------------------------------------------------------
// Three Step Studio
// Copyright GarageGames, LLC 2012
//-----------------------------------------------------------------------------

/// <ClassName>AnimationSet</ClassName>
/// <summary>
/// <para>An AnimationSet is actually a ScriptObject which acts as a 
/// container for dynamic fields related to Animation Set information. This will
/// only work if the ScriptObject is given the class of "AnimationSet"</para>
/// <para></para>
/// </summary>
/// <example> 
/// This sample shows how to create an AnimationSet by hand when you know what
/// the animation names and datablocks will be:
/// <code>
/// new ScriptObject(OrcAnimationSet)
/// {
///    northWalkAnimation = "orcNorthWalk";
///    southWalkAnimation = "orcSouthWalk";
///    eastWalkAnimation = "orcEastWalk";
///    westWalkAnimation = "orcWestWalk";
///    class = "AnimationSet";
/// };
/// </code>
/// If you only know the name of the set, you can dynamically create the fields and their values:
/// <code>
/// new ScriptObject(OrcAnimationSet){ class = "AnimationSet" };
/// OrcAnimationSet.AddAnimation("northWalkAnimation", "orcNorthWalk");
/// OrcAnimationSet.AddAnimation("eastWalkAnimation", "orcEastWalk");
/// OrcAnimationSet.AddAnimation("southWalkAnimation", "orcSouthWalk");
/// </code>
/// You can mix the above two examples together when you have a pre-defined set of animation names,
/// but you do not know the field values yet:
/// <code>
/// new ScriptObject(OrcAnimationSet)
/// {
///    northWalkAnimation = "";
///    southWalkAnimation = "";
///    eastWalkAnimation = "";
///    westWalkAnimation = "";
///    class = "AnimationSet";
/// };
/// OrcAnimationSet.ChangeDatablock("northWalkAnimation", "orcNorthWalk");
/// OrcAnimationSet.ChangeDatablock("southWalkAnimation", "orcSouthWalk");
/// OrcAnimationSet.ChangeDatablock("eastWalkAnimation", "orcEastWalk");
/// OrcAnimationSet.ChangeDatablock("westWalkAnimation", "orcWestWalk");
/// </code>
/// </example>
/// <seealso cref="ScriptObject"/>

/// <ClassMethod>AnimationSet</ClassMethod>
/// <summary>Returns the number of animations in the set</summary>
/// <returns>Numeric value of how many dynamic animation fields in ScriptObject</returns>
/// <example>
/// This example shows how to print out the number of animations in this set to the console:
/// <code>
/// %animationCount = OrcAnimationSet.GetAnimationCount();
/// echo("The Orc Animation Set contains" SPC %animationCount SPC "animations.");
/// </code>
/// </example>
function AnimationSet::GetAnimationCount(%this)
{
    return %this.getDynamicFieldCount();
}

/// <ClassMethod>AnimationSet::AddAnimation</ClassMethod>
/// <summary>
/// Adds a new animation field and corresponding datablock to the set </summary>
/// <param name="name">Name of the new animation field.</param>
/// <param name="animationDatablock">The AnimationAsset assigned to the new animation field</param>
/// <returns>True if the animation was successfully added. False if the field already existed or the animationDatablock is invalid</returns>
/// <example>
/// This example shows how to add a new animation and its value to a set. 
/// <code>OrcAnimationSet.AddAnimation("westWalkAnimation", "orcWestWalk");</code>
/// </example>
function AnimationSet::AddAnimation(%this, %name, %animationDatablock)
{
    if (%name $= "")
    {
        error("% - Invalid name specified for AnimationSet::AddAnimation");
        return false;
    }

    if (!isObject(%animationDatablock))
    {
        error("% - Invalid animation datablock specified for AnimationSet::AddAnimation");
        return false;
    }

    %this.setFieldValue(%name, %animationDatablock);

    return true;
}

/// <ClassMethod>AnimationSet::RemoveAnimation</ClassMethod>
/// <summary>
/// Deletes an animation field from the set. Note: Currently not implemented.
/// </summary>
/// <param name="parameterName">Parameter description</param>
/// <returns>Returns true if the animation was successfully removed. False if the animation did not exist</returns>
/// <example>
/// This example shows how to remove a specific animation from a set
/// <code>OrcAnimationSet.RemoveAnimation("westWalkAnimation");</code>
/// </example>
function AnimationSet::RemoveAnimation(%this, %name)
{
    error("% - Not implemented");
    return true;
}

/// <ClassMethod>AnimationSet::ChangeDatablock</ClassMethod>
/// <summary>
/// Changes the animation datablock on the specified field
/// </summary>
/// <param name="name">The animation field to modify</param>
/// <param name="animationDatablock">The new animation datablock</param>
/// <returns>Returns true if the change was successful. False if the animation does not exist or the animationDatablock is invalid</returns>
/// <example>
/// This example shows how to change the animation datablock for a specific animation in a set
/// <code>OrcAnimationSet.ChangeDatablock("westWalkAnimation", "orcWestWalk");</code>
/// </example>
function AnimationSet::ChangeDatablock(%this, %name, %animationDatablock)
{
    if (!isObject(%animationDatablock))
    {
        error("% - Invalid animation datablock specified for AnimationSet::ChangeDatablock");
        return false;
    }

    %fieldCount = %this.getDynamicFieldCount();

    for(%i = 0; %i < %fieldCount; %i++)
    {
        %currentField = %this.getDynamicField(%i);

        if (%currentField $= %name)
        {
            %this.setFieldValue(%name, %animationDatablock);
            return true;
        }
    }

/// <ClassMethod>AnimationSet::GetAnimationDatablock</ClassMethod>
/// <summary>
/// Accessor for the animation datablock on the specified animation field
/// </summary>
/// <param name="name">The name of the animation field</param>
/// <returns>Returns a AnimationAsset attached to the specified name. "" Will be returned if the specified name is invalid</returns>
/// <example>
/// This example shows how to get the AnimationAsset of a specific animation and print it to the console.
/// <code>
/// %animationDatablock = OrcAnimationSet.GetAnimationDatablock("westWalkAnimation");
/// echo("The Orc's west walk animation is " SPC %animationDatablock.getName());
/// </code>
/// </example>
function AnimationSet::GetAnimationDatablock(%this, %name)
{
    %animationDatablock = %this.getFieldValue(%name);

    if (%animationDatablock $= "")
        warn("% - Warning: Returning a null animation datablock in AnimationSet::GetAnimationDatablock");

    return %animationDatablock;
}

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Microsoft.Master2.rules
{
    class NavigationElement
    {
        private string className;

        public string ClassName
        {
            get { return className; }
            set { className = value; }
        }
        private string classMethod;

        public string ClassMethod
        {
            get { return classMethod; }
            set { classMethod = value; }
        }

        private ArrayList navigationElements = new ArrayList();

        public ArrayList NavigationElements
        {
            get { return navigationElements; }
            set { navigationElements = value; }
        }
    }
}

        
        private static string GetUniqueInterfaceMethodSignature(MethodInfo info)
        {
            var allNames = new List<string>();
            allNames.Add(info.Name);
            allNames.AddRange(info.GetParameters().Select(pInfo => pInfo.ParameterType.FullName));
            return string.Join("_", allNames);
        }

        private static IDictionary<string, HttpRequestParameters> BuildInterfaceMethodToParametersDictionary()
        {
            IEnumerable<MethodInfo> interfaceMethods = typeof(TServiceInterface).GetMethods()
                    .Where(method => HttpRestInterfaceValidator.ValidateInterfaceMethod(method));
            Dictionary<string, HttpRequestParameters> dictionary = interfaceMethods.ToDictionary(
                GetUniqueInterfaceMethodSignature, HttpRequestParameters.FromMethodInfo);
            return dictionary;
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "No need")]
        private HttpRequestMessage CreateHttpRequestMessage(HttpRequestParameters parameters, MethodInfo method, out CancellationToken cancellationToken, object[] methodArgumentsInOrder)
        {
            List<string> parameterNamesBoundToUri;
            var requestUri = parameters.BindUri(this._baseServiceUri, method, methodArgumentsInOrder, out parameterNamesBoundToUri, out cancellationToken);
            HttpRequestMessage requestMessage = new HttpRequestMessage(new HttpMethod(parameters.HttpMethod), requestUri);
           
            //The arguments when not used for uri binding either the request body or the cancellation token
            // the request body is serialized into the stream as the request body
            if (methodArgumentsInOrder.Length > parameterNamesBoundToUri.Count)
            {
                //This ordered as they appear in the method signature
                var parameterInfos = method.GetParameters();
                for (int i = 0; i < parameterInfos.Length; i++)
                {
                    var parameterName = parameterInfos[i].Name;
                    if (
                        !parameterNamesBoundToUri.Any(
                            paramName => paramName.Equals(parameterName, StringComparison.OrdinalIgnoreCase)))
                    {
                        if (parameterInfos[i].ParameterType != typeof(CancellationToken))
                        {
                            //Pick the unbound argument for request stream data
                            object dataToSerialize = methodArgumentsInOrder[i];
                            //serialize the data using the specified serializer into the request message
                            requestMessage.Content = new ObjectContent(dataToSerialize.GetType(), dataToSerialize, parameters.RequestFormatter.RequestFormatter);
                        }
                    }
                }
            }

            foreach (var formatter in parameters.ResponseFormatter.ResponseFormatters)
            {
                foreach (var mediaType in formatter.SupportedMediaTypes)
                {
                    requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(mediaType.MediaType));
                }
            }
            return requestMessage;
        }

        /// <summary>
        /// Creates the HTTP client by chaining all the handlers found in the interface method attributes and the http
        /// client configuration.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <returns>An instance of HttpClient.</returns>
        private HttpClient CreateHttpClient(HttpRequestParameters parameters)
        {
            HttpMessageHandler rootHandler = this.Configuration.RootHandler;
            if (parameters.CutomMessageProcessingHandlers.Any())
            {
                IList<DelegatingHandler> handlers =
                    parameters.CutomMessageProcessingHandlers.Select(c => c.CreateHandler()).ToList();
                for (int i = 0; i < handlers.Count - 1; i++)
                {
                    handlers[i].InnerHandler = handlers[i + 1];
                }

                handlers.Last().InnerHandler = this.Configuration.RootHandler;
                rootHandler = handlers.First();
            }
            else
            {
                rootHandler = this.Configuration.RootHandler;
            }

            return new HttpClient(rootHandler, false);
        }

        /// <summary>
        /// Creates the and invoke rest request for caller based of its interface implementation.
        /// </summary>
        /// <typeparam name="T">The return type.</typeparam>
        /// <param name="classMethod">The class verb.</param>
        /// <param name="methodArgumentsInOrder">The verb arguments in order.</param>
        /// <returns>A task.</returns>
        private async Task<T> InvokeHttpRestRequest<T>(MethodInfo classMethod, object[] methodArgumentsInOrder)
        {
            Contract.Requires<ArgumentNullException>(methodArgumentsInOrder != null);

            //Transform the reflected attributes from the method
            //Pull that information from the cache we created on construction
            var requestParametersFromMethod = this._methodToRequestParametersMap[GetUniqueInterfaceMethodSignature(classMethod)];
            Type returnType = null;
            if (classMethod.ReturnType.IsGenericType && classMethod.ReturnType.BaseType == typeof(Task))
            {
                returnType = classMethod.ReturnType.GetGenericArguments().Single();
            }
            else if (classMethod.ReturnType == typeof(void) || classMethod.ReturnType == typeof(Task))
            {
                returnType = typeof(void);
            }
            else
            {
                returnType = classMethod.ReturnType;
            }

            T retVal = default(T);
            for (int attempt = 1;; attempt++)
            {
                Exception lastException = null;
                TimeSpan delay = TimeSpan.MinValue;

                //Create the request message from the request parameters,i.e. set the headers and serialize the request
                CancellationToken cancellationToken;
                var requestMessage = this.CreateHttpRequestMessage(requestParametersFromMethod, classMethod, out cancellationToken, methodArgumentsInOrder);

                HttpClient client = this.CreateHttpClient(requestParametersFromMethod);
                client.Timeout = this.Configuration.HttpRequestTimeout;

                try
                {
                    using (var resp = await client.SendAsync(requestMessage, cancellationToken))
                    {
                        if (returnType == typeof(HttpResponseMessage))
                        {
                            return (T)(object)resp;
                        }

                        if (returnType != typeof(void))
                        {
                            retVal = (T)await resp.Content.ReadAsAsync(returnType, requestParametersFromMethod.ResponseFormatter.ResponseFormatters);
                            return retVal;
                        }

                        return default(T);
                    }
                }
                catch (Exception e)
                {
                    if (e is OperationCanceledException)
                    {
                        throw;
                    }

                    lastException = e;

                    if (!this.Configuration.RetryPolicy.ShouldRetry(e, attempt, out delay))
                    {
                        throw;
                    }
                }

                if (lastException != null)
                {
                    await Task.Delay(delay);
                }
            }
        }

        /// <summary>
        /// Creates and invokes the rest request for caller based of its interface definition.
        /// </summary>
        /// <param name="orderedArgumentsOfTheParentMethod">The ordered arguments of the parent verb.</param>
        /// <returns>A task.</returns>
        /// <remarks>Please be sure to dispose the HttpWebResponseObject after you are done with it.</remarks>
        protected Task<T> CreateAndInvokeRestRequestForParentMethodAsync<T>(params object[] orderedArgumentsOfTheParentMethod)
        {
            StackTrace stackTrace = new StackTrace();
            StackFrame stackFrame = stackTrace.GetFrame(1);
            //Get parent from the stackframe
            MethodInfo classMethod = (MethodInfo)stackFrame.GetMethod();
            return this.InvokeHttpRestRequest<T>(classMethod, orderedArgumentsOfTheParentMethod);
        }

IronPython.Runtime.classmethod : PythonTypeSlot

Constructors :

public classmethod(CodeContext context = , Object func = )

Methods :

public Object get___func__()
public Object __get__(Object instance = )
public Object __get__(Object instance = , Object owner = )
public Object __get__(CodeContext context = , Object instance = , Object typeContext = null)
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()