Microsoft.JScript.Class.CheckIfOKToGenerateCodeForExpando C# (CSharp) Method

CheckIfOKToGenerateCodeForExpando() private method

private CheckIfOKToGenerateCodeForExpando ( bool superClassIsExpando ) : void
superClassIsExpando bool
return void
      private void CheckIfOKToGenerateCodeForExpando(bool superClassIsExpando){
        if (superClassIsExpando){
          this.context.HandleError(JSError.BaseClassIsExpandoAlready);
          this.generateCodeForExpando = false;
          return;
        }
        
        // make sure the current class does not define an Item property
        if (this.classob.GetMember("Item", BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Instance|BindingFlags.Static|BindingFlags.DeclaredOnly).Length > 0){
          this.context.HandleError(JSError.ItemNotAllowedOnExpandoClass);
          this.generateCodeForExpando = false;
          return;
        }
        if (this.classob.GetMember("get_Item", BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Instance|BindingFlags.Static|BindingFlags.DeclaredOnly).Length > 0 ||
            this.classob.GetMember("set_Item", BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Instance|BindingFlags.Static|BindingFlags.DeclaredOnly).Length > 0){
          this.context.HandleError(JSError.MethodNotAllowedOnExpandoClass);
          this.generateCodeForExpando = false;
          return;
        }
            
        // make sure the current class does not implements IEnumerable
        if (this.ImplementsInterface(Typeob.IEnumerable)){
          this.context.HandleError(JSError.ExpandoClassShouldNotImpleEnumerable);
          this.generateCodeForExpando = false;
          return;
        }
              
        // make sure up in the hierarchy chain no property named 'Item' is defined
        if (this.superIR.GetMember("Item", BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Instance).Length > 0 ||
            this.superIR.GetMember("get_Item", BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Instance).Length > 0 ||
            this.superIR.GetMember("set_Item", BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Instance).Length > 0){
          this.context.HandleError(JSError.MethodClashOnExpandoSuperClass);
          this.generateCodeForExpando = false;
          return;
        }

        // add an expando property to the current class for Binding to find
        JSProperty itemProp = this.classob.itemProp = new JSProperty("Item");
        itemProp.getter = new JSExpandoIndexerMethod(this.classob, true);
        itemProp.setter = new JSExpandoIndexerMethod(this.classob, false);
        this.classob.AddNewField("Item", itemProp, FieldAttributes.Literal);
      }