コード例 #1
0
        public ClassAttributes GetDTOClassAttributes(string workSheet)
        {
            var classAttributes = new ClassAttributes(workSheet.GetClassName());

            classAttributes.Properties.AddRange(_dataProvider.GetColumns(workSheet));
            return(classAttributes);
        }
コード例 #2
0
        public static bool SaveCharacterDetailsAtCreate(String characterID, String userID, int classID)
        {
            ClassAttributes.GetClassAttributes(Convert.ToByte(classID), out int level, out int leben, out int exp, out int atk,
                                               out int mana, out int def, out int spd);

            String query = Queries.CreateCharacterDetail(Convert.ToInt32(characterID), level, leben, exp, atk, mana, def, spd);

            using (SQLiteConnection connection = new SQLiteConnection(GetConnectionString()))
            {
                SQLiteCommand     command = CreateCommandMeta(connection);
                SQLiteTransaction transaction;
                transaction         = connection.BeginTransaction();
                command.Transaction = transaction;
                try
                {
                    command.CommandText = query;
                    transaction.Commit();
                    return(command.ExecuteNonQuery() == 1);
                }
                catch (Exception)
                {
                    try
                    {
                        transaction.Rollback();
                    }
                    catch (Exception ex2)
                    {
                        throw new Exception(ex2.Message);
                    }
                    return(false);
                }
            }
        }
コード例 #3
0
ファイル: OutputFile.cs プロジェクト: bordev/Tobasco
        protected OutputFile()
        {
            var executingAssembly = Assembly.GetExecutingAssembly().GetName();

            Namespaces.Add("System");
            Namespaces.Add("System.CodeDom.Compiler");
            ClassAttributes.Add($"[GeneratedCode(\"{executingAssembly.Name}\", \"{executingAssembly.Version}\")]");
        }
コード例 #4
0
 public XamlParserContext(IDocumentContext documentContext, ClassAttributes rootAttributes)
 {
     if (documentContext == null)
     {
         throw new ArgumentNullException("documentContext");
     }
     this.documentContext = documentContext;
     this.namespaces      = new ClrNamespaceUriParseCache(this.TypeResolver);
     this.rootAttributes  = rootAttributes;
     this.errors          = (IList <XamlParseError>) new List <XamlParseError>();
 }
コード例 #5
0
        private void WalkType(INamedTypeSymbol typeSymbol)
        {
            var classAttribute = typeSymbol.GetPythonClassAttribute();

            if (classAttribute != null)
            {
                ClassAttributes.Add(typeSymbol, classAttribute);
            }

            foreach (var memberSymbol in typeSymbol.GetMembers())
            {
                switch (memberSymbol)
                {
                case IFieldSymbol fieldSymbol:
                    var fieldAttribute = fieldSymbol.GetPythonFieldAttribute();

                    if (fieldAttribute != null)
                    {
                        FieldAttributes.Add(fieldSymbol, fieldAttribute);
                    }

                    break;

                case IMethodSymbol methodSymbol:
                    var methodAttribute = methodSymbol.GetPythonMethodAttribute();

                    if (methodAttribute != null)
                    {
                        MethodAttributes.Add(methodSymbol, methodAttribute);
                    }

                    var operatorAttribute = methodSymbol.GetPythonOperatorAttribute();

                    if (operatorAttribute != null)
                    {
                        OperatorAttributes.Add(methodSymbol, operatorAttribute);
                    }

                    break;

                case IPropertySymbol propertySymbol:
                    var propertyAttribute = propertySymbol.GetPythonPropertyAttribute();

                    if (propertyAttribute != null)
                    {
                        PropertyAttributes.Add(propertySymbol, propertyAttribute);
                    }

                    break;
                }
            }
        }
コード例 #6
0
ファイル: Inspector.cs プロジェクト: kutselabskii/Citrus
        private static int CalcSelectedRowsHashcode()
        {
            var r = 0;

            if (CoreUserPreferences.Instance.InspectEasing)
            {
                r ^= FindMarkerBehind()?.GetHashCode() ?? 0;
            }
            if (Document.Current.Animation.IsCompound)
            {
                foreach (var track in GetSelectedAnimationTracksAndClips())
                {
                    r ^= track.GetHashCode();
                }
            }
            else if (Document.Current.InspectRootNode)
            {
                var rootNode = Document.Current.RootNode;
                r ^= rootNode.GetHashCode();
                foreach (var component in rootNode.Components)
                {
                    r ^= component.GetHashCode();
                }
            }
            else
            {
                foreach (var row in Document.Current.Rows)
                {
                    if (row.Selected)
                    {
                        r ^= row.GetHashCode();
                        var node = row.Components.Get <NodeRow>()?.Node;
                        if (node != null)
                        {
                            foreach (var component in node.Components)
                            {
                                if (ClassAttributes <NodeComponentDontSerializeAttribute> .Get(component.GetType()) != null)
                                {
                                    continue;
                                }
                                r ^= component.GetHashCode();
                            }
                        }
                    }
                }
            }
            return(r);
        }
コード例 #7
0
            public void SetUp()
            {
                _excelRepository = MockRepository.GenerateMock<IRepository>();
                _classGenerator = MockRepository.GenerateMock<IClassGenerator>();
                _assemblyGenerator = MockRepository.GenerateMock<IAssemblyGenerator>();
                _fileConfiguration = MockRepository.GenerateMock<IFileConfiguration>();
                _excelToDtoMapper = new ExcelToDTOMapper(_excelRepository, _classGenerator, _assemblyGenerator,
                                                         _fileConfiguration);

                _excelFiles = new List<string>
                                  {
                                      "TestExcel.xls"
                                  };
                _workSheetNames = new List<string>
                                      {
                                          "Test1$",
                                          "Test2$"
                                      };
                _classAttributes1 = new ClassAttributes("Test1");
                _classAttributes2 = new ClassAttributes("Test2");
            }
コード例 #8
0
            public void SetUp()
            {
                _excelRepository   = MockRepository.GenerateMock <IRepository>();
                _classGenerator    = MockRepository.GenerateMock <IClassGenerator>();
                _assemblyGenerator = MockRepository.GenerateMock <IAssemblyGenerator>();
                _fileConfiguration = MockRepository.GenerateMock <IFileConfiguration>();
                _excelToDtoMapper  = new ExcelToDTOMapper(_excelRepository, _classGenerator, _assemblyGenerator,
                                                          _fileConfiguration);

                _excelFiles = new List <string>
                {
                    "TestExcel.xls"
                };
                _workSheetNames = new List <string>
                {
                    "Test1$",
                    "Test2$"
                };
                _classAttributes1 = new ClassAttributes("Test1");
                _classAttributes2 = new ClassAttributes("Test2");
            }
コード例 #9
0
ファイル: Modification.cs プロジェクト: aologos/Citrus
        public static Node Perform(Node container, FolderItemLocation location, Type nodeType)
        {
            if (!nodeType.IsSubclassOf(typeof(Node)))
            {
                throw new InvalidOperationException();
            }
            var ctr   = nodeType.GetConstructor(Type.EmptyTypes);
            var node  = (Node)ctr.Invoke(new object[] { });
            var attrs = ClassAttributes <TangerineNodeBuilderAttribute> .Get(nodeType);

            if (attrs?.MethodName != null)
            {
                var builder = nodeType.GetMethod(attrs.MethodName, BindingFlags.NonPublic | BindingFlags.Instance);
                builder.Invoke(node, new object[] { });
            }
            node.Id = GenerateNodeId(container, nodeType);
            InsertFolderItem.Perform(container, location, node);
            ClearRowSelection.Perform();
            SelectNode.Perform(node);
            Document.Current.Decorate(node);
            return(node);
        }
コード例 #10
0
        public bool Run(string assemblyName, List <string> files)
        {
            List <ClassAttributes> classAttributesList = new List <ClassAttributes>();

            foreach (string file in files)
            {
                _fileConfiguration.FileName = file;
                foreach (string workSheet in _excelRepository.GetWorkSheetNames())
                {
                    ClassAttributes classAttributes = _excelRepository.GetDTOClassAttributes(workSheet);
                    classAttributes.Namespace = String.Format("{0}.{1}", assemblyName, Path.GetFileNameWithoutExtension(file));

                    if (classAttributes.Properties.Count == 0)
                    {
                        continue;
                    }
                    _classGenerator.Create(classAttributes);
                    classAttributesList.Add(classAttributes);
                }
            }
            return((classAttributesList.Count > 0) &&
                   _assemblyGenerator.Compile(classAttributesList.Select(x => x.FullName).ToArray(), new AssemblyAttributes(assemblyName)));
        }
コード例 #11
0
 public ClassRepresentationBuilder WithClassAttributes(params string[] classAttributes)
 {
     ClassAttributes.AddRange(classAttributes);
     return(this);
 }
コード例 #12
0
 private void CancelAllEdits()
 {
     ClassAttributes.CancelEdit();
     txtClassName.myEditable        = false;
     txtElementNameLabel.myEditable = false;
 }
コード例 #13
0
ファイル: LibraryServices.cs プロジェクト: vic-kailiu/Dynamo
        private void ImportProcedure(string library, ProcedureNode proc)
        {
            string procName = proc.name;

            if (proc.isAutoGeneratedThisProc ||
                CoreUtils.IsSetter(procName) ||
                CoreUtils.IsDisposeMethod(procName) ||
                CoreUtils.StartsWithDoubleUnderscores(procName))
            {
                return;
            }

            int              classScope      = proc.classScope;
            string           className       = string.Empty;
            MethodAttributes methodAttribute = proc.MethodAttribute;
            ClassAttributes  classAttribute  = null;

            if (classScope != ProtoCore.DSASM.Constants.kGlobalScope)
            {
                var classNode = GraphUtilities.GetCore().ClassTable.ClassNodes[classScope];

                classAttribute = classNode.ClassAttributes;
                className      = classNode.name;
            }

            // MethodAttribute's HiddenInLibrary has higher priority than
            // ClassAttribute's HiddenInLibrary
            bool isVisible = true;

            if (methodAttribute != null)
            {
                isVisible = !methodAttribute.HiddenInLibrary;
            }
            else
            {
                if (classAttribute != null)
                {
                    isVisible = !classAttribute.HiddenInLibrary;
                }
            }

            FunctionType type;

            if (classScope == ProtoCore.DSASM.Constants.kGlobalScope)
            {
                type = FunctionType.GenericFunction;
            }
            else
            {
                if (CoreUtils.IsGetter(procName))
                {
                    type = proc.isStatic
                        ? FunctionType.StaticProperty
                        : FunctionType.InstanceProperty;

                    string property;
                    if (CoreUtils.TryGetPropertyName(procName, out property))
                    {
                        procName = property;
                    }
                }
                else
                {
                    if (proc.isConstructor)
                    {
                        type = FunctionType.Constructor;
                    }
                    else if (proc.isStatic)
                    {
                        type = FunctionType.StaticMethod;
                    }
                    else
                    {
                        type = FunctionType.InstanceMethod;
                    }
                }
            }

            IEnumerable <TypedParameter> arguments = proc.argInfoList.Zip(
                proc.argTypeList,
                (arg, argType) =>
            {
                object defaultValue = null;
                if (arg.IsDefault)
                {
                    var binaryExpr = arg.DefaultExpression as BinaryExpressionNode;
                    if (binaryExpr != null)
                    {
                        AssociativeNode vnode = binaryExpr.RightNode;
                        if (vnode is IntNode)
                        {
                            defaultValue = (vnode as IntNode).Value;
                        }
                        else if (vnode is DoubleNode)
                        {
                            defaultValue = (vnode as DoubleNode).Value;
                        }
                        else if (vnode is BooleanNode)
                        {
                            defaultValue = (vnode as BooleanNode).Value;
                        }
                        else if (vnode is StringNode)
                        {
                            defaultValue = (vnode as StringNode).value;
                        }
                    }
                }

                return(new TypedParameter(arg.Name, argType.ToString(), defaultValue));
            });

            IEnumerable <string> returnKeys = null;

            if (proc.MethodAttribute != null && proc.MethodAttribute.ReturnKeys != null)
            {
                returnKeys = proc.MethodAttribute.ReturnKeys;
            }

            var function = new FunctionDescriptor(
                library,
                className,
                procName,
                arguments,
                proc.returntype.ToString(),
                type,
                isVisible,
                returnKeys,
                proc.isVarArg);

            AddImportedFunctions(library, new[] { function });
        }
コード例 #14
0
ファイル: PIM_Class.cs プロジェクト: mff-uk/xcase
 private void CancelAllEdits()
 {
     ClassAttributes.CancelEdit();
     ClassOperations.CancelEdit();
     txtClassName.myEditable = false;
 }
コード例 #15
0
        public override void Execute()
        {
            string               fileName           = "test";
            IProject             activeProject      = this.DesignerContext.ActiveProject;
            TemplateItemHelper   templateItemHelper = new TemplateItemHelper(activeProject, (IList <string>)null, (IServiceProvider)this.DesignerContext.Services);
            IProjectItemTemplate templateItem       = templateItemHelper.FindTemplateItem("UserControl");

            if (templateItem == null)
            {
                this.DesignerContext.MessageDisplayService.ShowError(StringTable.MakeUserControlTemplateNotFound);
            }
            else
            {
                SceneViewModel      activeSceneViewModel = this.DesignerContext.ActiveSceneViewModel;
                List <SceneElement> elements             = new List <SceneElement>();
                elements.AddRange((IEnumerable <SceneElement>)activeSceneViewModel.ElementSelectionSet.Selection);
                elements.Sort((IComparer <SceneElement>) new ZOrderComparer <SceneElement>(activeSceneViewModel.RootNode));
                if (this.ShowUI)
                {
                    string recommendedName = this.GetRecommendedName((IEnumerable <SceneElement>)elements);
                    MakeUserControlDialog userControlDialog = new MakeUserControlDialog(this.DesignerContext, this.DialogTitle, templateItemHelper, recommendedName);
                    bool?nullable = userControlDialog.ShowDialog();
                    if ((!nullable.GetValueOrDefault() ? 1 : (!nullable.HasValue ? true : false)) != 0)
                    {
                        return;
                    }
                    fileName = userControlDialog.ControlName;
                }
                List <IProjectItem>        itemsToOpen  = (List <IProjectItem>)null;
                IProjectItem               projectItem1 = (IProjectItem)null;
                IEnumerable <IProjectItem> source       = (IEnumerable <IProjectItem>)null;
                try
                {
                    source = templateItemHelper.AddProjectItemsForTemplateItem(templateItem, fileName, this.DesignerContext.ProjectManager.TargetFolderForProject(activeProject), CreationOptions.DoNotAllowOverwrites | CreationOptions.DoNotSelectCreatedItems | CreationOptions.DoNotSetDefaultImportPath, out itemsToOpen);
                }
                catch (Exception ex)
                {
                    if (ex is NotSupportedException || ErrorHandling.ShouldHandleExceptions(ex))
                    {
                        this.DesignerContext.MessageDisplayService.ShowError(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.ProjectNewFileErrorDialogMessage, new object[2]
                        {
                            (object)fileName,
                            (object)ex.Message
                        }));
                    }
                    else
                    {
                        throw;
                    }
                }
                if (source == null || EnumerableExtensions.CountIsLessThan <IProjectItem>(source, 1))
                {
                    return;
                }
                if (itemsToOpen != null && itemsToOpen.Count > 0)
                {
                    projectItem1 = Enumerable.FirstOrDefault <IProjectItem>((IEnumerable <IProjectItem>)itemsToOpen);
                    projectItem1.OpenDocument(false, true);
                }
                if (projectItem1 != null && projectItem1.IsOpen && projectItem1.DocumentType.CanView)
                {
                    Rect empty = Rect.Empty;
                    for (int index = 0; index < elements.Count; ++index)
                    {
                        BaseFrameworkElement child = elements[index] as BaseFrameworkElement;
                        if (child != null)
                        {
                            Rect childRect = child.ViewModel.GetLayoutDesignerForChild((SceneElement)child, true).GetChildRect(child);
                            empty.Union(childRect);
                        }
                    }
                    Rect         rect              = RoundingHelper.RoundRect(empty);
                    SceneElement parentElement     = elements[0].ParentElement;
                    bool         useLayoutRounding = LayoutRoundingHelper.GetUseLayoutRounding(parentElement);
                    DataObject   dataObject        = (DataObject)null;
                    using (activeSceneViewModel.ForceBaseValue())
                    {
                        PastePackage pastePackage = new PastePackage(activeSceneViewModel);
                        pastePackage.CopyStoryboardsReferencingElements = true;
                        pastePackage.AddElements(elements);
                        dataObject = pastePackage.GetPasteDataObject();
                    }
                    SceneView sceneView = projectItem1.OpenView(true) as SceneView;
                    if (sceneView != null)
                    {
                        SceneViewModel     viewModel           = sceneView.ViewModel;
                        ProjectXamlContext projectXamlContext  = ProjectXamlContext.FromProjectContext(viewModel.ViewRoot.ProjectContext);
                        ClassAttributes    rootClassAttributes = viewModel.DocumentRoot.RootClassAttributes;
                        ITypeId            typeId = (ITypeId)null;
                        if (projectXamlContext != null && rootClassAttributes != null)
                        {
                            projectXamlContext.RefreshUnbuiltTypeDescriptions();
                            if (rootClassAttributes != null)
                            {
                                typeId = (ITypeId)projectXamlContext.GetType(projectXamlContext.ProjectAssembly.Name, rootClassAttributes.QualifiedClassName);
                            }
                        }
                        if (typeId != null && this.CheckForCircularReference((IEnumerable <SceneElement>)elements, typeId))
                        {
                            this.DesignerContext.MessageDisplayService.ShowError(StringTable.MakeUserControlCircularReferenceFound);
                            this.CleanupAfterCancel(projectItem1);
                            return;
                        }
                        using (SceneEditTransaction editTransaction = viewModel.CreateEditTransaction(StringTable.UndoUnitMakeUserControl))
                        {
                            if (!rect.IsEmpty)
                            {
                                viewModel.RootNode.SetValue(DesignTimeProperties.DesignWidthProperty, (object)rect.Width);
                                viewModel.RootNode.SetValue(DesignTimeProperties.DesignHeightProperty, (object)rect.Height);
                                if (this.AddToApplicationFlow)
                                {
                                    viewModel.RootNode.SetValue(BaseFrameworkElement.WidthProperty, (object)rect.Width);
                                    viewModel.RootNode.SetValue(BaseFrameworkElement.HeightProperty, (object)rect.Height);
                                }
                            }
                            IProperty property = LayoutRoundingHelper.ResolveUseLayoutRoundingProperty(viewModel.RootNode);
                            if (property != null)
                            {
                                viewModel.RootNode.SetValue((IPropertyId)property, (object)(bool)(useLayoutRounding ? true : false));
                            }
                            ILayoutDesigner         designerForParent = viewModel.GetLayoutDesignerForParent(viewModel.ActiveSceneInsertionPoint.SceneElement, true);
                            bool                    canceledPasteOperation;
                            ICollection <SceneNode> nodes = PasteCommand.PasteData(viewModel, new SafeDataObject((IDataObject)dataObject), viewModel.ActiveSceneInsertionPoint, out canceledPasteOperation);
                            if (canceledPasteOperation)
                            {
                                editTransaction.Cancel();
                                this.CleanupAfterCancel(projectItem1);
                                return;
                            }
                            editTransaction.Update();
                            if (nodes.Count > 0)
                            {
                                viewModel.DefaultView.UpdateLayout();
                                viewModel.SelectNodes(nodes);
                                if (designerForParent != null)
                                {
                                    foreach (SceneNode sceneNode in (IEnumerable <SceneNode>)nodes)
                                    {
                                        BaseFrameworkElement child = sceneNode as BaseFrameworkElement;
                                        if (child != null && child.IsViewObjectValid)
                                        {
                                            Rect childRect = child.ViewModel.GetLayoutDesignerForChild((SceneElement)child, true).GetChildRect(child);
                                            childRect.Location = (Point)(childRect.Location - rect.Location);
                                            designerForParent.SetChildRect(child, childRect);
                                        }
                                    }
                                }
                            }
                            editTransaction.Commit();
                        }
                        if (this.AddToApplicationFlow && this.DesignerContext.PrototypingService != null)
                        {
                            this.DesignerContext.PrototypingService.PromoteToCompositionScreen(projectItem1);
                        }
                        if (typeId != null)
                        {
                            using (activeSceneViewModel.ForceBaseValue())
                            {
                                using (activeSceneViewModel.DisableDrawIntoState())
                                {
                                    using (SceneEditTransaction editTransaction = activeSceneViewModel.CreateEditTransaction(StringTable.UndoUnitMakeUserControl))
                                    {
                                        using (activeSceneViewModel.DisableUpdateChildrenOnAddAndRemove())
                                        {
                                            SceneElement primarySelection = activeSceneViewModel.ElementSelectionSet.PrimarySelection;
                                            IProperty    propertyForChild = parentElement.GetPropertyForChild((SceneNode)primarySelection);
                                            PropertySceneInsertionPoint sceneInsertionPoint = new PropertySceneInsertionPoint(parentElement, propertyForChild);
                                            SceneNode sceneNode = (SceneNode)null;
                                            if (sceneInsertionPoint.CanInsert(typeId))
                                            {
                                                foreach (SceneElement element in elements)
                                                {
                                                    if (element != primarySelection)
                                                    {
                                                        activeSceneViewModel.AnimationEditor.DeleteAllAnimationsInSubtree(element);
                                                        element.Remove();
                                                    }
                                                }
                                                ISceneNodeCollection <SceneNode> collectionForProperty = parentElement.GetCollectionForProperty((IPropertyId)propertyForChild);
                                                int index = collectionForProperty.IndexOf((SceneNode)primarySelection);
                                                activeSceneViewModel.AnimationEditor.DeleteAllAnimationsInSubtree(primarySelection);
                                                primarySelection.Remove();
                                                sceneNode = activeSceneViewModel.CreateSceneNode(typeId);
                                                collectionForProperty.Insert(index, sceneNode);
                                                this.DesignerContext.ViewService.ActiveView = (IView)activeSceneViewModel.DefaultView;
                                                editTransaction.Update();
                                                activeSceneViewModel.DefaultView.UpdateLayout();
                                                BaseFrameworkElement child = sceneNode as BaseFrameworkElement;
                                                if (child != null && child.IsViewObjectValid)
                                                {
                                                    activeSceneViewModel.GetLayoutDesignerForParent(parentElement, true).SetChildRect(child, rect);
                                                }
                                            }
                                            if (this.AddToApplicationFlow)
                                            {
                                                if (sceneNode != null)
                                                {
                                                    sceneNode.SetValue(DesignTimeProperties.IsPrototypingCompositionProperty, (object)true);
                                                }
                                            }
                                        }
                                        editTransaction.Commit();
                                    }
                                }
                            }
                            this.DesignerContext.ViewService.ActiveView = (IView)viewModel.DefaultView;
                        }
                    }
                }
                if (itemsToOpen == null || itemsToOpen.Count <= 1)
                {
                    return;
                }
                foreach (IProjectItem projectItem2 in itemsToOpen)
                {
                    if (projectItem1 != projectItem2)
                    {
                        projectItem2.OpenView(true);
                    }
                }
            }
        }
コード例 #16
0
        public ReactElement <HTMLAttributes <HTMLDivElement> > Render()
        {
            // Create label:
            Intersection <ClassAttributes <HTMLLabelElement>, HTMLAttributes <HTMLLabelElement> > labelConfig =
                new ClassAttributes <HTMLLabelElement>
            {
                key = "label1"
            };
            var labelNode = DOM.label.Self(labelConfig, props.Label).AsNode();

            // Create input:
            Intersection <ClassAttributes <HTMLInputElement>, ChangeTargetHTMLAttributes <HTMLInputElement> > inputConfig =
                new ChangeTargetHTMLAttributes <HTMLInputElement>
            {
                style = new CSSProperties
                {
                    marginLeft = 20,
                },
                value    = state.Value,
                onChange = Handler.ChangeEvent <HTMLInputElement>(e =>
                {
                    setState(new State {
                        Value = e.currentTarget.Type2.value
                    });
                })
            };

            inputConfig.Type1.key = "input1";
            var inputNode = DOM.input.Self(inputConfig).AsNode();

            // Create button:
            Intersection <ClassAttributes <HTMLButtonElement>, HTMLAttributes <HTMLButtonElement> > buttonConfig =
                new HTMLAttributes <HTMLButtonElement>
            {
                style = new CSSProperties
                {
                    height     = 28,
                    width      = 150,
                    marginLeft = 20,
                },
                dangerouslySetInnerHTML = new DOMAttributes <HTMLButtonElement> .dangerouslySetInnerHTMLConfig()
                {
                    __html = string.IsNullOrWhiteSpace(state.Value) ? "Enter text" : "Print to Console",
                },
                disabled = string.IsNullOrWhiteSpace(state.Value),
                onClick  = Handler.MouseEvent <HTMLButtonElement>(e => props.OnSave(state.Value))
            };

            buttonConfig.Type1.key = "button1";
            var buttonNode = DOM.button.Self(buttonConfig).AsNode();

            // Create div:
            var div = DOM.div.Self(new HTMLAttributes <HTMLDivElement> {
                className = "wrapper"
            }, new [] {
                labelNode,
                inputNode,
                buttonNode
            });

            return(div);
        }
コード例 #17
0
ファイル: LibraryServices.cs プロジェクト: undeadinu/Dynamo
        private void ImportProcedure(string library, ProcedureNode proc)
        {
            string procName = proc.Name;

            if (proc.IsAutoGeneratedThisProc ||
                // There could be DS functions that have private access
                // that shouldn't be imported into the Library
                proc.AccessModifier == AccessModifier.Private ||
                CoreUtils.IsSetter(procName) ||
                CoreUtils.IsDisposeMethod(procName) ||
                CoreUtils.StartsWithDoubleUnderscores(procName))
            {
                return;
            }

            string           obsoleteMessage = "";
            int              classScope      = proc.ClassID;
            string           className       = string.Empty;
            MethodAttributes methodAttribute = proc.MethodAttribute;
            ClassAttributes  classAttribute  = null;

            if (classScope != Constants.kGlobalScope)
            {
                var classNode = LibraryManagementCore.ClassTable.ClassNodes[classScope];

                classAttribute = classNode.ClassAttributes;
                className      = classNode.Name;
            }

            // MethodAttribute's HiddenInLibrary has higher priority than
            // ClassAttribute's HiddenInLibrary
            var isVisible             = true;
            var canUpdatePeriodically = false;

            if (methodAttribute != null)
            {
                isVisible             = !methodAttribute.HiddenInLibrary;
                canUpdatePeriodically = methodAttribute.CanUpdatePeriodically;
            }
            else
            {
                if (classAttribute != null)
                {
                    isVisible = !classAttribute.HiddenInLibrary;
                }
            }

            FunctionType type;

            if (classScope == Constants.kGlobalScope)
            {
                type = FunctionType.GenericFunction;
            }
            else
            {
                if (CoreUtils.IsGetter(procName))
                {
                    type = proc.IsStatic
                        ? FunctionType.StaticProperty
                        : FunctionType.InstanceProperty;

                    string property;
                    if (CoreUtils.TryGetPropertyName(procName, out property))
                    {
                        procName = property;
                    }
                }
                else
                {
                    if (proc.IsConstructor)
                    {
                        type = FunctionType.Constructor;
                    }
                    else if (proc.IsStatic)
                    {
                        type = FunctionType.StaticMethod;
                    }
                    else
                    {
                        type = FunctionType.InstanceMethod;
                    }
                }
            }

            List <TypedParameter> arguments = proc.ArgumentInfos.Zip(
                proc.ArgumentTypes,
                (arg, argType) =>
            {
                AssociativeNode defaultArgumentNode;
                // Default argument specified by DefaultArgumentAttribute
                // takes higher priority
                if (!TryGetDefaultArgumentFromAttribute(arg, out defaultArgumentNode) &&
                    arg.IsDefault)
                {
                    var binaryExpr = arg.DefaultExpression as BinaryExpressionNode;
                    if (binaryExpr != null)
                    {
                        defaultArgumentNode = binaryExpr.RightNode;
                    }
                }
                string shortName = null;
                if (defaultArgumentNode != null)
                {
                    shortName           = defaultArgumentNode.ToString();
                    var rewriter        = new ElementRewriter(LibraryManagementCore.ClassTable, LibraryManagementCore.BuildStatus.LogSymbolConflictWarning);
                    defaultArgumentNode = defaultArgumentNode.Accept(rewriter);
                }
                return(new TypedParameter(arg.Name, argType, defaultArgumentNode, shortName));
            }).ToList();

            bool isLacingDisabled           = false;
            IEnumerable <string> returnKeys = null;

            if (proc.MethodAttribute != null)
            {
                if (proc.MethodAttribute.ReturnKeys != null)
                {
                    returnKeys = proc.MethodAttribute.ReturnKeys;
                }
                if (proc.MethodAttribute.IsObsolete)
                {
                    obsoleteMessage = proc.MethodAttribute.ObsoleteMessage;
                }
                isLacingDisabled = proc.MethodAttribute.IsLacingDisabled;
            }

            var function = new FunctionDescriptor(new FunctionDescriptorParams
            {
                Assembly              = library,
                ClassName             = className,
                FunctionName          = procName,
                Parameters            = arguments,
                ReturnType            = proc.ReturnType,
                FunctionType          = type,
                IsVisibleInLibrary    = isVisible,
                ReturnKeys            = returnKeys,
                PathManager           = pathManager,
                IsVarArg              = proc.IsVarArg,
                ObsoleteMsg           = obsoleteMessage,
                CanUpdatePeriodically = canUpdatePeriodically,
                IsBuiltIn             = pathManager.PreloadedLibraries.Contains(library),
                IsPackageMember       = packagedLibraries.Contains(library),
                IsLacingDisabled      = isLacingDisabled
            });

            AddImportedFunctions(library, new[] { function });
        }
コード例 #18
0
        public override StringBuilder Generate()
        {
            StringBuilder builder       = new();
            var           currentIndent = 0;

            if (!string.IsNullOrWhiteSpace(Namespace))
            {
                builder.Append($"package {Namespace};{NewLine}{NewLine}");
            }

            if (Imports.Count > 0)
            {
                builder.Append("import " + string.Join($";{NewLine}import ", Imports.Where(i => !i.Equals(Namespace))) + $";{NewLine}{NewLine}");
            }

            ClassAttributes.ForEach(attr =>
            {
                IndentStringBuilder(builder, currentIndent);

                builder.Append($"{attr}{NewLine}");
            });

            IndentStringBuilder(builder, currentIndent);
            builder.Append($"{ClassAccess} class {FileName}");

            if (Relations.Any(r => r.RelationType == ClassRelationType.Inheritance && r.Target.Type == FileType.Class))
            {
                builder.Append(
                    $" extends {Relations.First(r => r.RelationType == ClassRelationType.Inheritance && r.Target.Type == FileType.Class).Target.Name}");
            }

            if (Relations.Any(r => r.RelationType == ClassRelationType.Inheritance && r.Target.Type == FileType.Interface))
            {
                builder.Append(" implements " + string.Join(", ", Relations.Where(r => r.RelationType == ClassRelationType.Inheritance && r.Target.Type == FileType.Interface).Select(x => x.Target.Name)));
            }

            IndentStringBuilder(builder.Append(NewLine), currentIndent++);
            builder.Append($"{{{NewLine}");

            FieldsAndProperties.ForEach(d =>
            {
            });

            Constructors.ForEach(ctr =>
            {
                IndentStringBuilder(builder, currentIndent);

                builder.Append($"{Helper.ToString(ctr.Access)} {ctr.NameType.Name}({string.Join(", ", ctr.Params.Select(p => $"{p.Type} {p.Name}"))}){{{NewLine}");
                IndentStringBuilder(builder, ++currentIndent);
                builder.Append($"{NewLine}");
                IndentStringBuilder(builder, --currentIndent);
                builder.Append($"}}{NewLine}");
            });
            Methods.ForEach(m =>
            {
                IndentStringBuilder(builder, currentIndent);

                builder.Append($"{Helper.ToString(m.Access)} {m.NameType.Type} {m.NameType.Name}({string.Join(", ", m.Params.Select(p => $"{p.Type} {p.Name}"))}){NewLine}");
                IndentStringBuilder(builder, currentIndent);
                builder.Append($"{{{NewLine}");
                IndentStringBuilder(builder, ++currentIndent);
                builder.Append($"{NewLine}");
                IndentStringBuilder(builder, --currentIndent);
                builder.Append($"}}{NewLine}");
            });

            //builder.Append(NewLine);
            IndentStringBuilder(builder, currentIndent);
            builder.Append(NewLine);
            IndentStringBuilder(builder, --currentIndent);
            return(builder.Append('}'));
        }
コード例 #19
0
 public string GetClassAttributesAsString()
 {
     return(ClassAttributes.Aggregate("", (current, classAttribute) => current + ("[" + classAttribute + "]" + Environment.NewLine)));
 }
コード例 #20
0
ファイル: LibraryServices.cs プロジェクト: tylerputnam/Dynamo
        private void ImportProcedure(string library, ProcedureNode proc)
        {
            string procName = proc.name;

            if (proc.isAutoGeneratedThisProc ||
                CoreUtils.IsSetter(procName) ||
                CoreUtils.IsDisposeMethod(procName) ||
                CoreUtils.StartsWithDoubleUnderscores(procName))
            {
                return;
            }

            string           obsoleteMessage = "";
            int              classScope      = proc.classScope;
            string           className       = string.Empty;
            MethodAttributes methodAttribute = proc.MethodAttribute;
            ClassAttributes  classAttribute  = null;

            if (classScope != Constants.kGlobalScope)
            {
                var classNode = LibraryManagementCore.ClassTable.ClassNodes[classScope];

                classAttribute = classNode.ClassAttributes;
                className      = classNode.name;
            }

            // MethodAttribute's HiddenInLibrary has higher priority than
            // ClassAttribute's HiddenInLibrary
            var isVisible             = true;
            var canUpdatePeriodically = false;

            if (methodAttribute != null)
            {
                isVisible             = !methodAttribute.HiddenInLibrary;
                canUpdatePeriodically = methodAttribute.CanUpdatePeriodically;
            }
            else
            {
                if (classAttribute != null)
                {
                    isVisible = !classAttribute.HiddenInLibrary;
                }
            }

            FunctionType type;

            if (classScope == Constants.kGlobalScope)
            {
                type = FunctionType.GenericFunction;
            }
            else
            {
                if (CoreUtils.IsGetter(procName))
                {
                    type = proc.isStatic
                        ? FunctionType.StaticProperty
                        : FunctionType.InstanceProperty;

                    string property;
                    if (CoreUtils.TryGetPropertyName(procName, out property))
                    {
                        procName = property;
                    }
                }
                else
                {
                    if (proc.isConstructor)
                    {
                        type = FunctionType.Constructor;
                    }
                    else if (proc.isStatic)
                    {
                        type = FunctionType.StaticMethod;
                    }
                    else
                    {
                        type = FunctionType.InstanceMethod;
                    }
                }
            }

            List <TypedParameter> arguments = proc.argInfoList.Zip(
                proc.argTypeList,
                (arg, argType) =>
            {
                AssociativeNode defaultArgumentNode;
                // Default argument specified by DefaultArgumentAttribute
                // takes higher priority
                if (!TryGetDefaultArgumentFromAttribute(arg, out defaultArgumentNode) &&
                    arg.IsDefault)
                {
                    var binaryExpr = arg.DefaultExpression as BinaryExpressionNode;
                    if (binaryExpr != null)
                    {
                        defaultArgumentNode = binaryExpr.RightNode;
                    }
                }

                return(new TypedParameter(arg.Name, argType, defaultArgumentNode));
            }).ToList();

            IEnumerable <string> returnKeys = null;

            if (proc.MethodAttribute != null)
            {
                if (proc.MethodAttribute.ReturnKeys != null)
                {
                    returnKeys = proc.MethodAttribute.ReturnKeys;
                }
                if (proc.MethodAttribute.IsObsolete)
                {
                    obsoleteMessage = proc.MethodAttribute.ObsoleteMessage;
                }
            }

            var function = new FunctionDescriptor(new FunctionDescriptorParams
            {
                Assembly              = library,
                ClassName             = className,
                FunctionName          = procName,
                Parameters            = arguments,
                ReturnType            = proc.returntype,
                FunctionType          = type,
                IsVisibleInLibrary    = isVisible,
                ReturnKeys            = returnKeys,
                PathManager           = pathManager,
                IsVarArg              = proc.isVarArg,
                ObsoleteMsg           = obsoleteMessage,
                CanUpdatePeriodically = canUpdatePeriodically,
                IsBuiltIn             = pathManager.PreloadedLibraries.Contains(library)
            });

            AddImportedFunctions(library, new[] { function });
        }
コード例 #21
0
        public ReactElement <HTMLAttributes <HTMLDivElement> > Render()
        {
            // Create label:
            Intersection <ClassAttributes <HTMLLabelElement>, HTMLAttributes <HTMLLabelElement> > labelConfig =
                new ClassAttributes <HTMLLabelElement>
            {
                key = "label1"
            };

            var labelNode = createElement("label", labelConfig).AsNode();


            // Create input:
            Intersection <ClassAttributes <HTMLInputElement>, InputHTMLAttributes <HTMLInputElement> > inputConfig =
                new InputHTMLAttributes <HTMLInputElement>
            {
                style = new CSSProperties
                {
                    marginLeft = (Union <string, double>) 20
                },
                value    = state.Value,
                onChange = Handler.ChangeEvent <HTMLInputElement>(e =>
                {
                    state = new State {
                        Value = e.target.Type2.value
                    };
                    setState <KeyOf <State> >(state);
                    //System.Console.WriteLine(e.target.Type2.value);
                    //System.Console.WriteLine(state.Value);
                })
            };

            inputConfig.Type1.key = "input1";
            var inputNode = createElement("input", inputConfig).AsNode();

            // Create button:
            Intersection <ClassAttributes <HTMLButtonElement>, ButtonHTMLAttributes <HTMLButtonElement> > buttonConfig =
                new ButtonHTMLAttributes <HTMLButtonElement>
            {
                style = new CSSProperties
                {
                    height     = (Union <string, double>) 28,
                    width      = (Union <string, double>) 150,
                    marginLeft = (Union <string, double>) 20
                },
                dangerouslySetInnerHTML = new DOMAttributes <HTMLButtonElement> .dangerouslySetInnerHTMLConfig()
                {
                    __html = string.IsNullOrWhiteSpace(state.Value) ? "Enter text" : "Print to Console",
                },
                disabled = string.IsNullOrWhiteSpace(state.Value),
                onClick  = Handler.MouseEvent <HTMLButtonElement>(e =>
                {
                    props.OnSave(state.Value);
                })
            };

            buttonConfig.Type1.key = "button1";
            var buttonNode = createElement("button", buttonConfig).AsNode();

            // Create div:
            Intersection <ClassAttributes <HTMLDivElement>, HTMLAttributes <HTMLDivElement> > divConfig =
                new HTMLAttributes <HTMLDivElement>
            {
                className = "wrapper"
            };

            var div = createElement("div", divConfig, new[]
            {
                labelNode,
                inputNode,
                buttonNode
            });

            return(div);
        }