Beispiel #1
0
 private void finishSelection()
 {
     if (SelectedIndex >= 0)
     {
         MadeSelection = true;
         Selection     = ((ConstructorDisplay)Items[SelectedIndex]).Constructor;
     }
     _service.CloseDropDown();
 }
Beispiel #2
0
            public override void SetValue(object component, object value)
            {
                ConstructorClass cc = value as ConstructorClass;

                if (cc != null)
                {
                    _owner._constructor.SetConstructor(cc);
                }
            }
Beispiel #3
0
            public void SetConstructor(ConstructorClass constructor)
            {
                _constructor = constructor;
                List <ParameterClass> ps = _constructor.Parameters;

                if (ps != null && ps.Count > 0)
                {
                    this.ResetParameterTypes();
                    foreach (ParameterClass p in ps)
                    {
                        this.Parameters.Add(p.Name, p.BaseClassType);
                    }
                }
            }
Beispiel #4
0
 public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
 {
     if (context != null && context.Instance != null)
     {
         MethodDiagramViewer mdv = context.Instance as MethodDiagramViewer;
         if (mdv != null)
         {
             WebClientEventHandlerMethod wcehm = mdv.Method as WebClientEventHandlerMethod;
             if (wcehm != null)
             {
                 if (string.CompareOrdinal("ReturnType", context.PropertyDescriptor.Name) == 0)
                 {
                     return(UITypeEditorEditStyle.None);
                 }
             }
         }
         DataTypePointer dp = context.Instance as DataTypePointer;
         if (dp != null)
         {
             if (dp.ReadOnly)
             {
                 return(UITypeEditorEditStyle.None);
             }
             ParameterClass pc = dp as ParameterClass;
             if (pc != null)
             {
                 ConstructorClass cc = pc.Method as ConstructorClass;
                 if (cc != null)
                 {
                     ClassPointer cp = cc.Owner as ClassPointer;
                     if (cp != null)
                     {
                         if (typeof(Attribute).IsAssignableFrom(cp.BaseClassType))
                         {
                             return(UITypeEditorEditStyle.DropDown);
                         }
                     }
                 }
             }
         }
     }
     return(UITypeEditorEditStyle.Modal);
 }
Beispiel #5
0
    static void  Main()
    {
        // create an Account object and assign it to myAccount
        Account myAccount = new  Account();

        // display myAccount's initial name (there isn't one yet)
        Console.WriteLine($"Initial name is: {myAccount.GetName()}");

        // prompt for and read the name, then put the name in the object
        Console.Write("Enter the name: ");   // prompt
        string theName = Console.ReadLine(); // read the name

        myAccount.SetName(theName);          // put theName in the myAccount object

        // display the name stored in the myAccount object
        Console.WriteLine($"myAccount's name is: {myAccount.GetName()}");


        //using constructor
        ConstructorClass mycon = new ConstructorClass("mike mead");

        Console.WriteLine($"Constructor name is: {mycon.Name}");
    }
Beispiel #6
0
 public void LoadBuiltinClasses()
 {
     classes["Int"]               = new IntClass();
     classes["Float"]             = new FloatClass();
     classes["Boolean"]           = new BooleanClass();
     classes["String"]            = new StringClass();
     classes["Char"]              = new CharClass();
     classes["Byte"]              = new ByteClass();
     classes["Message"]           = new MessageClass();
     classes["Unassigned"]        = new UnassignedClass();
     classes["Tuple"]             = new TupleClass();
     classes["NameValue"]         = new NameValueClass();
     classes["Lambda"]            = new LambdaClass();
     classes["Void"]              = new VoidClass();
     classes["Some"]              = new SomeClass();
     classes["None"]              = new NoneClass();
     classes["Array"]             = new ArrayClass();
     classes["Iterator"]          = new IteratorClass();
     classes["LazyIterator"]      = new LazyIteratorClass();
     classes["StreamIterator"]    = new StreamIteratorClass();
     classes["Any"]               = new AnyClass();
     classes["Placeholder"]       = new PlaceholderClass();
     classes["Range"]             = new RangeClass();
     classes["Dictionary"]        = new DictionaryClass();
     classes["Container"]         = new ContainerClass();
     classes["Unmatched"]         = new UnmatchedClass();
     classes["Complex"]           = new ComplexClass();
     classes["Rational"]          = new RationalClass();
     classes["Long"]              = new LongClass();
     classes["Lazy"]              = new LazyClass();
     classes["YieldingInvokable"] = new YieldingInvokableClass();
     classes["Del"]               = new DelClass();
     classes["Slice"]             = new SliceClass();
     classes["End"]               = new EndClass();
     classes["List"]              = new ListClass();
     classes["Arguments"]         = new ArgumentsClass();
     classes["Symbol"]            = new SymbolClass();
     classes["Infinity"]          = new InfinityClass();
     classes["OpenRange"]         = new OpenRangeClass();
     classes["KeyValue"]          = new KeyValueClass();
     classes["Regex"]             = new RegexClass();
     classes["Pattern"]           = new PatternClass();
     classes["PackageFunction"]   = new PackageFunctionClass();
     classes["Sys"]               = new SysClass();
     classes["Math"]              = new MathClass();
     classes["RuntimeFunction"]   = new RuntimeFunctionClass();
     classes["Reference"]         = new ReferenceClass();
     classes["Group"]             = new RegexGroupClass();
     classes["Match"]             = new RegexMatchClass();
     classes["Date"]              = new DateClass();
     classes["Interval"]          = new IntervalClass();
     classes["TypeConstraint"]    = new TypeConstraintClass();
     classes["ByteArray"]         = new ByteArrayClass();
     classes["Selector"]          = new SelectorClass();
     classes["Number"]            = new NumberClass();
     classes["Collection"]        = new CollectionClass();
     classes["TextFinding"]       = new TextFindingClass();
     classes["SkipTake"]          = new SkipTakeClass();
     classes["Constructor"]       = new ConstructorClass();
     classes["MutString"]         = new MutStringClass();
     classes["Error"]             = new ErrorClass();
     classes["Success"]           = new SuccessClass();
     classes["Failure"]           = new FailureClass();
     classes["Optional"]          = new OptionalClass();
     classes["Result"]            = new ResultClass();
     classes["Monad"]             = new MonadClass();
     classes["Unit"]              = new UnitClass();
     classes["YieldReturn"]       = new YieldReturnClass();
     classes["Index"]             = new IndexClass();
     classes["Cycle"]             = new CycleClass();
     classes["Set"]               = new SetClass();
 }
Beispiel #7
0
 public ConstructorDisplay(ConstructorClass c)
 {
     Constructor = c;
 }
Beispiel #8
0
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if (context != null && context.Instance != null && provider != null)
     {
         IWindowsFormsEditorService service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
         if (service != null)
         {
             DataTypePointer  typeScope = null;
             ITypeScopeHolder th        = context.Instance as ITypeScopeHolder;
             if (th != null)
             {
                 typeScope = th.GetTypeScope(context.PropertyDescriptor.Name);
             }
             if (typeScope == null)
             {
                 foreach (Attribute a in context.PropertyDescriptor.Attributes)
                 {
                     TypeScopeAttribute ts = a as TypeScopeAttribute;
                     if (ts != null && ts.Scope != null)
                     {
                         if (ts.Scope.IsGenericParameter)
                         {
                             Type[] ctps = ts.Scope.GetGenericParameterConstraints();
                             if (ctps != null && ctps.Length > 0)
                             {
                                 typeScope = new DataTypePointer(new TypePointer(ctps[0]));
                                 break;
                             }
                         }
                         else
                         {
                             typeScope = new DataTypePointer(new TypePointer(ts.Scope));
                             break;
                         }
                     }
                 }
             }
             MethodClass        scopeMethod = null;
             IScopeMethodHolder mh          = context.Instance as IScopeMethodHolder;
             if (mh != null)
             {
                 scopeMethod = mh.GetScopeMethod();
             }
             IWithProject mc = context.Instance as IWithProject;
             if (mc == null)
             {
                 ComponentInterfaceWrapper ciw = context.Instance as ComponentInterfaceWrapper;
                 if (ciw != null)
                 {
                     mc = ciw.Value as IWithProject;
                 }
             }
             if (mc == null)
             {
                 MathNode.Log(TraceLogClass.GetForm(provider), new DesignerException("{0} does not implement IWithProject", context.Instance.GetType()));
             }
             else
             {
                 if (mc.Project == null)
                 {
                     MathNode.Log(TraceLogClass.GetForm(provider), new DesignerException("Project not set for {0} [{1}]", mc, mc.GetType()));
                 }
                 else
                 {
                     MethodDiagramViewer mdv = mc as MethodDiagramViewer;
                     if (mdv != null)
                     {
                         WebClientEventHandlerMethod wcehm = mdv.Method as WebClientEventHandlerMethod;
                         if (wcehm != null)
                         {
                             if (string.CompareOrdinal("ReturnType", context.PropertyDescriptor.Name) == 0)
                             {
                                 return(value);
                             }
                         }
                     }
                     bool            isMethodReturn = false;
                     IObjectPointer  op             = value as IObjectPointer;
                     DataTypePointer val            = new DataTypePointer();
                     if (op != null)
                     {
                         val.SetDataType(op);
                     }
                     for (int i = 0; i < context.PropertyDescriptor.Attributes.Count; i++)
                     {
                         MethodReturnAttribute mra = context.PropertyDescriptor.Attributes[i] as MethodReturnAttribute;
                         if (mra != null)
                         {
                             isMethodReturn = true;
                             break;
                         }
                     }
                     //
                     bool                   bUseDropDown = false;
                     EnumWebRunAt           runAt        = EnumWebRunAt.Inherit;
                     PropertyClassWebClient pcwc         = context.Instance as PropertyClassWebClient;
                     if (pcwc != null)
                     {
                         bUseDropDown = true;
                         runAt        = EnumWebRunAt.Client;
                     }
                     else
                     {
                         PropertyClassWebServer pcws = context.Instance as PropertyClassWebServer;
                         if (pcws != null)
                         {
                             bUseDropDown = true;
                             runAt        = EnumWebRunAt.Server;
                         }
                     }
                     if (!bUseDropDown)
                     {
                         ParameterClass pc = context.Instance as ParameterClass;
                         if (pc != null)
                         {
                             ConstructorClass cc = pc.Method as ConstructorClass;
                             if (cc != null)
                             {
                                 ClassPointer cp = cc.Owner as ClassPointer;
                                 if (cp != null)
                                 {
                                     if (typeof(Attribute).IsAssignableFrom(cp.BaseClassType))
                                     {
                                         //use drop down
                                         bUseDropDown = true;
                                     }
                                 }
                             }
                         }
                     }
                     //
                     if (bUseDropDown)
                     {
                         TypeSelector drp = TypeSelector.GetAttributeParameterDialogue(service, runAt, val.BaseClassType);
                         service.DropDownControl(drp);
                         if (drp.SelectedType != null)
                         {
                             val.SetDataType(drp.SelectedType);
                             bool bIsForLocalType = false;
                             if (string.Compare(context.PropertyDescriptor.Name, ActionAssignInstance.Instance_Type, StringComparison.Ordinal) == 0)
                             {
                                 PropertiesWrapper pw = context.Instance as PropertiesWrapper;
                                 if (pw != null)
                                 {
                                     AB_SingleAction sa = pw.Owner as AB_SingleAction;
                                     if (sa != null)
                                     {
                                         ActionAssignInstance aa = sa.ActionData as ActionAssignInstance;
                                         if (aa != null)
                                         {
                                             bIsForLocalType = true;
                                             aa.SetParameterValue(ConstObjectPointer.VALUE_Type, drp.SelectedType);
                                         }
                                     }
                                 }
                             }
                             if (bIsForLocalType)
                             {
                             }
                             else
                             {
                                 value = val;
                             }
                         }
                     }
                     else
                     {
                         Type        typeAttr = null;
                         MethodClass mc0      = scopeMethod;
                         if (mc0 == null)
                         {
                             mc0 = mc as MethodClass;
                         }
                         if (mc0 == null)
                         {
                             MethodDiagramViewer mcv = mc as MethodDiagramViewer;
                             if (mcv != null)
                             {
                                 mc0 = mcv.Method;
                             }
                         }
                         if (mc0 != null)
                         {
                             if (mc.Project.ProjectType == EnumProjectType.WebAppPhp)
                             {
                                 if (mc0.WebUsage == EnumMethodWebUsage.Server)
                                 {
                                     typeAttr = typeof(PhpTypeAttribute);
                                 }
                                 else
                                 {
                                     typeAttr = typeof(JsTypeAttribute);
                                 }
                             }
                             else if (mc.Project.ProjectType == EnumProjectType.WebAppAspx)
                             {
                                 if (mc0.WebUsage == EnumMethodWebUsage.Client)
                                 {
                                     typeAttr = typeof(JsTypeAttribute);
                                 }
                             }
                         }
                         FrmObjectExplorer dlg = DesignUtil.GetDataTypeSelectionDialogue(mc.Project, scopeMethod, val, isMethodReturn, typeScope, typeAttr);
                         if (service.ShowDialog(dlg) == DialogResult.OK)
                         {
                             val.SetDataType(dlg.SelectedDataType);
                             bool bIsForLocalType = false;
                             if (string.Compare(context.PropertyDescriptor.Name, ActionAssignInstance.Instance_Type, StringComparison.Ordinal) == 0)
                             {
                                 PropertiesWrapper pw = context.Instance as PropertiesWrapper;
                                 if (pw != null)
                                 {
                                     AB_SingleAction sa = pw.Owner as AB_SingleAction;
                                     if (sa != null)
                                     {
                                         ActionAssignInstance aa = sa.ActionData as ActionAssignInstance;
                                         if (aa != null)
                                         {
                                             bIsForLocalType = true;
                                             aa.SetParameterValue(ActionAssignInstance.Instance_Type, dlg.SelectedDataType);
                                         }
                                     }
                                 }
                             }
                             else
                             {
                                 ComponentIconLocal cil = context.Instance as ComponentIconLocal;
                                 bIsForLocalType = (cil != null);
                                 if (bIsForLocalType)
                                 {
                                     cil.LocalPointer.ClassType = dlg.SelectedDataType;
                                 }
                             }
                             if (bIsForLocalType)
                             {
                             }
                             else
                             {
                                 ExceptionHandlerList.PropertyDescriptorExceptionHandler pdeh = context.PropertyDescriptor as ExceptionHandlerList.PropertyDescriptorExceptionHandler;
                                 if (pdeh != null)
                                 {
                                     pdeh.Handler.ExceptionType = val;
                                 }
                                 else
                                 {
                                     value = val;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return(value);
 }
 public void Should_only_allow_new_expressions_for_injection_constructors()
 {
     var obj = new ConstructorClass();
     container.RegisterType(new InjectionConstructor<ConstructorClass>(() => obj));
 }