Пример #1
0
 public void BindData(MetaField field)
 {
     if (field.Attributes.ContainsKey(McDataTypeAttribute.BooleanLabel))
     {
         chkValue.Text = CommonHelper.GetResFileString(field.Attributes[McDataTypeAttribute.BooleanLabel].ToString());
     }
 }
Пример #2
0
        /// <summary>
        /// Adds the new meta field.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="friendlyName">Name of the friendly.</param>
        /// <param name="typeName">Name of the type.</param>
        /// <param name="isNullable">if set to <c>true</c> [is nullable].</param>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="attributes">The attributes.</param>
        /// <returns></returns>
        public MetaField AddNewMetaField(string name,
                                         string friendlyName,
                                         string typeName,
                                         bool isNullable,
                                         string defaultValue,
                                         AttributeCollection attributes)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            // Check Meta Field Name. Should be unique
            CheckMetaFieldName(name);

            MetaField mf = CreateNewMetaField(name,
                                              friendlyName,
                                              typeName,
                                              isNullable,
                                              defaultValue,
                                              attributes);

            this.NewMetaFields.Add(mf);

            return(mf);
        }
Пример #3
0
        /// <summary>
        /// Creates the new list default mapping.
        /// </summary>
        protected virtual void CreateNewListDefaultMapping()
        {
            MappingElement mapping = new MappingElement(this.SourceTableName, this.DestinationMetaClassName);

            this.MappingDocument.Add(mapping);

            if (this.ExternalData == null || this.ExternalData.Tables.Count == 0)
            {
                return;
            }

            foreach (DataColumn column in this.GetSourceColumns())
            {
                // TODO: Exclude PrimaryKey

                if (column.ColumnName == "Created" ||
                    column.ColumnName == "CreatorId" ||
                    column.ColumnName == "Modified" ||
                    column.ColumnName == "ModifierId")
                {
                    continue;
                }


                MetaField field = CreateNewMetaField(column);

                this.NewMetaFields.Add(field);

                AssignCopyValueRule(column.ColumnName, field.Name);
            }
        }
 public void Initialize(MetaField field)
 {
     if (!field.MemberType.IsAssignableFrom(typeof(Tuple <double, double>)))
     {
         throw new ArgumentException("Member type should be assignable from System.Tuple<double, double>.");
     }
 }
Пример #5
0
        public DataControlField GetColumn(Page pageInstance, MetaField field, bool isPrimaryKey)
        {
            if (pageInstance == null)
                throw new ArgumentNullException("pageInstance");
            if (field == null)
                throw new ArgumentNullException("field");

            if (ControlPathResolver.Current == null)
                throw new ArgumentNullException("ControlPathResolver");

            TemplateField retVal = new TemplateField();

            if (!isPrimaryKey)
            {
                ResolvedPath resPath = ControlPathResolver.Current.Resolve(CHelper.GetMetaTypeName(field), "Grid", field.Owner.Name, field.Name, viewName);

                //retVal.ItemTemplate = PageInstance.LoadTemplate(MetaFieldControlPathResolver.Resolve(CHelper.GetMetaTypeName(Field)/*Field.TypeName*/, "Grid", Field.Owner.Name, Field.Name, viewName, string.Empty));
                if(resPath!= null)
                    retVal.ItemTemplate = pageInstance.LoadTemplate(resPath.Path);
            }
            else
                retVal.ItemTemplate = pageInstance.LoadTemplate("~/Apps/MetaUI/Primitives/Text.Grid.@[email protected]");

            return retVal;
        }
Пример #6
0
        private void ShowField(MetaField field)
        {
            field.Opacity = 1.0f;

            // If the field is a reflexive, recursively set the opacity of its children
            var reflexive = field as ReflexiveData;

            if (reflexive != null)
            {
                // Show wrappers
                _flattener.EnumWrappers(reflexive, ShowField);

                // Show template fields
                foreach (MetaField child in reflexive.Template)
                {
                    ShowField(child);
                }

                // Show modified fields
                foreach (ReflexivePage page in reflexive.Pages)
                {
                    foreach (MetaField child in page.Fields)
                    {
                        if (child != null)
                        {
                            ShowField(child);
                        }
                    }
                }
            }
        }
Пример #7
0
            private MethodDeclarationSyntax CreateParamsElementArrayMethod(MetaField field, IdentifierNameSyntax methodName, SimpleNameSyntax collectionMutationMethodName, bool passThroughChildSync = false)
            {
                var paramsArrayMethod = CreateMethodStarter(methodName.Identifier, field)
                                        .WithParameterList(CreateParamsElementArrayParameters(field));

                var lambdaParameter = SyntaxFactory.Parameter(SyntaxFactory.Identifier("v"));
                var argument        = passThroughChildSync
                    ? (ExpressionSyntax)Syntax.EnumerableExtension(
                    SyntaxFactory.IdentifierName(nameof(Enumerable.Select)),
                    ValuesParameterName,
                    SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(
                                                   SyntaxFactory.Argument(Syntax.ThisDot(SyncImmediateChildToCurrentVersionMethodName)))))
                    : ValuesParameterName;

                paramsArrayMethod = this.AddMethodBody(
                    paramsArrayMethod,
                    field,
                    receiver => SyntaxFactory.InvocationExpression(
                        SyntaxFactory.MemberAccessExpression(
                            SyntaxKind.SimpleMemberAccessExpression,
                            receiver,
                            collectionMutationMethodName),
                        SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(
                                                       SyntaxFactory.Argument(argument)))));

                return(paramsArrayMethod);
            }
Пример #8
0
        public void BindData(MetaField mf)
        {
            FillItems(false);

            object value = mf.Attributes[RoleTypeAttribute.PermittedPrincipalTypes];
            if (value != null)
            {
                List<int> lst = new List<int>((int[])value);

                foreach (DataGridItem dgi in MainGrid.Items)
                {
                    foreach (Control control in dgi.Cells[1].Controls)
                    {
                        if (control is CheckBox)
                        {
                            CheckBox checkBox = (CheckBox)control;
                            int itemId = int.Parse(dgi.Cells[0].Text);

                            if (lst.Contains(itemId))
                                checkBox.Checked = true;
                        }
                    }
                }
            }
        }
 internal static MethodDeclarationSyntax CreateIEnumerableFromParamsArrayMethod(MetaField field, MethodDeclarationSyntax paramsArrayMethod)
 {
     return paramsArrayMethod
         .WithParameterList(SyntaxFactory.ParameterList(SyntaxFactory.SingletonSeparatedList(
             SyntaxFactory.Parameter(ValuesParameterName.Identifier)
                 .WithType(Syntax.IEnumerableOf(GetFullyQualifiedSymbolName(field.ElementType))))));
 }
Пример #10
0
        /// <summary>
        /// Loads the request variables.
        /// </summary>
        private void LoadRequestVariables()
        {
            if (Request.QueryString["class"] != null)
            {
                ClassName = Request.QueryString["class"];
                mc        = MetaDataWrapper.GetMetaClassByName(ClassName);
            }

            if (mc != null && Request.QueryString["field"] != null)
            {
                FieldName = Request.QueryString["field"];
                mf        = mc.Fields[FieldName];
            }

            if (Request.QueryString["refclass"] != null)
            {
                RefClassName = Request.QueryString["refclass"];
                mcRef        = MetaDataWrapper.GetMetaClassByName(RefClassName);
            }

            if (mcRef != null && Request.QueryString["reffield"] != null)
            {
                RefFieldName = Request.QueryString["reffield"];
                mfRef        = mcRef.Fields[RefFieldName];
            }

            if (Request.QueryString["mode"] != null)
            {
                Mode = Request.QueryString["mode"].ToUpperInvariant();
            }
        }
Пример #11
0
        public void InitControl(int FieldId)
        {
            fieldId = FieldId;
            MetaField field = MetaField.Load(fieldId);

            btnEditItems.Visible = false;
            if (Security.IsManager() && field.DataType == MetaDataType.DictionaryMultivalue)
            {
                btnEditItems.Visible = true;
                btnEditItems.Attributes.Add("onclick", String.Format("EditItems({0})", fieldId));

                if (!Page.ClientScript.IsClientScriptBlockRegistered("EditItems"))
                {
                    String scriptString = "<script language=JavaScript>\r\n";
                    scriptString += "function EditItems(FieldId)\r\n";
                    scriptString += "{\r\n";
                    scriptString += "	var w = 640;\r\n";
                    scriptString += "	var h = 350;\r\n";
                    scriptString += "	var l = (screen.width - w) / 2;\r\n";
                    scriptString += "	var t = (screen.height - h) / 2;\r\n";
                    scriptString += "	var winprops = 'resizable=0, height='+h+',width='+w+',top='+t+',left='+l;\r\n";
                    scriptString += String.Format("	window.open('{0}?Id=' + FieldId, 'EditItems', winprops);\r\n", ResolveUrl("~/Common/MetaDictionary.aspx"));
                    scriptString += "}\r\n";
                    scriptString += "</script>\r\n";

                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "EditItems", scriptString);
                }
            }
        }
Пример #12
0
        public async Task <ActionResult> CustomFieldUpdate(int?id)
        {
            MetaField field;

            if (id.HasValue)
            {
                var fieldQuery = await _customFieldService.Query(x => x.ID == id).Include(x => x.MetaCategories).SelectAsync();

                field = fieldQuery.FirstOrDefault();
            }
            else
            {
                field = new MetaField()
                {
                    Required   = false,
                    Searchable = false
                }
            };

            var categories = await _categoryService.Query().SelectAsync();

            var model = new MetaFieldModel()
            {
                MetaField  = field,
                Categories = categories.ToList()
            };

            return(View(model));
        }
Пример #13
0
        /// <summary>
        /// Resolves the meta control.
        /// </summary>
        /// <param name="metaClass">The meta class.</param>
        /// <param name="metaField">The meta field.</param>
        /// <returns></returns>
        private string ResolveMetaControl(MetaClass metaClass, MetaField metaField)
        {
            string basePath    = "~/Apps/Core/MetaData/Controls/";
            string controlName = GetControlNameForMetaType(metaField.DataType);

            string fullPath = String.Format("{0}{1}.{2}.{3}.ascx", basePath, metaClass.Name, metaField.Name, controlName);

            if (File.Exists(Server.MapPath(fullPath)))
            {
                return(fullPath);
            }

            fullPath = String.Format("{0}{1}.{2}.ascx", basePath, metaField.Name, controlName);

            if (File.Exists(Server.MapPath(fullPath)))
            {
                return(fullPath);
            }


            fullPath = String.Format("{0}{1}.{2}.ascx", basePath, metaClass.Name, controlName);

            if (File.Exists(Server.MapPath(fullPath)))
            {
                return(fullPath);
            }

            return(String.Format("{0}{1}.ascx", basePath, controlName));
        }
Пример #14
0
        private MetaField CreateMetaField(MetaDataContext mdContext, string metaDataNamespace, string name, MetaDataType type, int length, bool allowNulls, bool cultureSpecific)
        {
            var f = MetaField.Load(mdContext, name) ??
                    MetaField.Create(mdContext, metaDataNamespace, name, name, string.Empty, type, length, allowNulls, cultureSpecific, false, false);

            return(f);
        }
Пример #15
0
        /// <summary>
        /// Sets MetaFile and Image values
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="obj">The obj.</param>
        /// <param name="fieldName">Name of the field.</param>
        /// <param name="name">The name.</param>
        /// <param name="contentType">Type of the content.</param>
        /// <param name="fileContents">The file contents.</param>
        /// <returns></returns>
        public static bool SetMetaFile(MetaDataContext context, MetaObject obj, string fieldName, string name, string contentType, byte[] fileContents)
        {
            MetaField mf = MetaField.Load(context, fieldName);

            if (mf == null || (mf.DataType != MetaDataType.File && mf.DataType != MetaDataType.Image && mf.DataType != MetaDataType.ImageFile))
            {
                return(false);
            }

            // assign default meta field value if value is not specified and meta field doesn't allow null values
            if (fileContents == null || fileContents.Length == 0)
            {
                if (!mf.AllowNulls)
                {
                    obj[mf.Name] = MetaObject.GetDefaultValue(mf.DataType);
                }
                else
                {
                    obj[mf.Name] = null;
                }
                return(true);
            }

            // assign the file value
            MetaFile metaFile = new MetaFile(name, contentType, fileContents);

            obj[mf.Name] = metaFile;

            return(true);
        }
Пример #16
0
        /// <summary>
        /// Gets the meta field value.
        /// </summary>
        /// <param name="mf">The mf.</param>
        /// <param name="value">The value.</param>
        /// <returns></returns>
        public static object GetMetaFieldValue(MetaField mf, object value)
        {
            if (value == null)
            {
                return(value);
            }

            if (mf.DataType == MetaDataType.DictionarySingleValue || mf.DataType == MetaDataType.EnumSingleValue)
            {
                return(((MetaDictionaryItem)value).Value);
            }
            else if (mf.DataType == MetaDataType.DictionaryMultiValue || mf.DataType == MetaDataType.EnumMultiValue)
            {
                ArrayList arr = new ArrayList();
                foreach (MetaDictionaryItem item in (MetaDictionaryItem[])value)
                {
                    arr.Add(item.Value);
                }

                return((string[])arr.ToArray(typeof(string)));
            }
            else
            {
                return(value);
            }
        }
Пример #17
0
        public void BindData(MetaField mf)
        {
            CultureInfo invariantCulture = new CultureInfo("");

            if (mf.Attributes.ContainsKey(McDataTypeAttribute.DoubleMinValue))
            {
                txtMinValue.Text = ((double)mf.Attributes[McDataTypeAttribute.DoubleMinValue]).ToString("f");
            }
            else
            {
                txtMinValue.Text = "";
            }

            if (mf.Attributes.ContainsKey(McDataTypeAttribute.DoubleMaxValue))
            {
                txtMaxValue.Text = ((double)mf.Attributes[McDataTypeAttribute.DoubleMaxValue]).ToString("f");
            }
            else
            {
                txtMaxValue.Text = "";
            }

            if (mf.DefaultValue != String.Empty)
            {
                txtDefaultValue.Text = ((double)DefaultValue.Evaluate(mf)).ToString("f");
            }
            else
            {
                txtDefaultValue.Text = "";
            }
        }
Пример #18
0
        /// <summary>
        /// Binds the available fields.
        /// </summary>
        private void BindAvailableFields()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("MetaFieldId", typeof(int));
            dt.Columns.Add("FriendlyName", typeof(string));

            // Fields
            MetaFieldCollection mfc = MetaField.GetList(MDContext);

            foreach (MetaField field in mfc)
            {
                if (field.IsUser)
                {
                    DataRow row = dt.NewRow();
                    row["MetaFieldId"]  = field.Id;
                    row["FriendlyName"] = field.FriendlyName;
                    dt.Rows.Add(row);
                }
            }

            /*
             *          ItemsGrid.DataSource = new DataView(dt);
             *          ItemsGrid.DataBind();
             * */
        }
Пример #19
0
        public void BindData(MetaField mf)
        {
            ViewState[this.ClientID + "_TypeName"] = mf.TypeName;

            MetaFieldType mft = DataContext.Current.MetaModel.RegisteredTypes[mf.TypeName];

            trName.Visible       = false;
            txtFriendlyName.Text = mft.FriendlyName;

            if (mf.Attributes.ContainsKey(McDataTypeAttribute.EnumEditable))
            {
                chkEditable.Checked = (bool)mf.Attributes[McDataTypeAttribute.EnumEditable];
            }

            if (mft.Attributes.ContainsKey(McDataTypeAttribute.EnumPrivate) &&
                mft.Attributes[McDataTypeAttribute.EnumPrivate].ToString() == mf.Owner.Name)
            {
                chkPublic.Checked = false;
            }
            else
            {
                chkPublic.Checked = true;
            }

            chkPublic.Enabled = false;
        }
Пример #20
0
        public DataControlField GetColumn(Page pageInstance, MetaField field, bool isPrimaryKey)
        {
            if (pageInstance == null)
            {
                throw new ArgumentNullException("pageInstance");
            }
            if (field == null)
            {
                throw new ArgumentNullException("field");
            }

            if (ControlPathResolver.Current == null)
            {
                throw new ArgumentNullException("ControlPathResolver");
            }

            TemplateField retVal = new TemplateField();

            if (!isPrimaryKey)
            {
                ResolvedPath resPath = ControlPathResolver.Current.Resolve(CHelper.GetMetaTypeName(field), "Grid", field.Owner.Name, field.Name, viewName);

                //retVal.ItemTemplate = PageInstance.LoadTemplate(MetaFieldControlPathResolver.Resolve(CHelper.GetMetaTypeName(Field)/*Field.TypeName*/, "Grid", Field.Owner.Name, Field.Name, viewName, string.Empty));
                if (resPath != null)
                {
                    retVal.ItemTemplate = pageInstance.LoadTemplate(resPath.Path);
                }
            }
            else
            {
                retVal.ItemTemplate = pageInstance.LoadTemplate("~/Apps/MetaUI/Primitives/Text.Grid.@[email protected]");
            }

            return(retVal);
        }
Пример #21
0
        protected override void FillSystemColumnInfo(System.Collections.ArrayList array)
        {
            MetaClass mc = MetaClass.Load(Context, _metaClassId);

            FillType fillTypes = FillType.CopyValue | FillType.Custom | FillType.Default;

            array.Add(new ColumnInfo(MetaField.CreateVirtual(this.Context, "eCF.50.Import", "sys_RowAction", "Action (Insert/Update/Delete or I/U/D)", "", MetaDataType.NVarChar, 6, true, false, false, false, false), fillTypes));

            //Entry
            array.Add(new ColumnInfo(MetaField.CreateVirtual(this.Context, "eCF.50.Import", "Code", "Code<sup>1,2</sup>", "", MetaDataType.NVarChar, 100, false, false, false, false, false), fillTypes));
            array.Add(new ColumnInfo(MetaField.CreateVirtual(this.Context, "eCF.50.Import", "Name", "Name<sup>1</sup>", "", MetaDataType.NVarChar, 100, true, false, false, false, false), fillTypes));
            array.Add(new ColumnInfo(MetaField.CreateVirtual(this.Context, "eCF.50.Import", "ClassTypeId", "Entry Type<sup>1</sup>", "", MetaDataType.NVarChar, 50, true, false, false, false, false), fillTypes, true));
            array.Add(new ColumnInfo(MetaField.CreateVirtual(this.Context, "eCF.50.Import", "StartDate", "Available from", "", MetaDataType.DateTime, 8, true, false, false, false, false), fillTypes));
            array.Add(new ColumnInfo(MetaField.CreateVirtual(this.Context, "eCF.50.Import", "EndDate", "Expires on", "", MetaDataType.DateTime, 8, true, false, false, false, false), fillTypes));
            array.Add(new ColumnInfo(MetaField.CreateVirtual(this.Context, "eCF.50.Import", "TemplateName", "Display Template", "", MetaDataType.NVarChar, 50, true, false, false, false, false), fillTypes, true));
            array.Add(new ColumnInfo(MetaField.CreateVirtual(this.Context, "eCF.50.Import", "IsActive", "Available (True/False)", "", MetaDataType.Bit, 1, true, false, false, false, false), fillTypes));
            array.Add(new ColumnInfo(MetaField.CreateVirtual(this.Context, "eCF.50.Import", "CategoryCode", "Category Code (by comma)", "", MetaDataType.ShortString, 255, true, false, false, false, false), fillTypes));
            array.Add(new ColumnInfo(MetaField.CreateVirtual(this.Context, "eCF.50.Import", "SortOrder", "Sort Order", "", MetaDataType.Int, 4, true, false, false, false, false), fillTypes));

            //SEO
            array.Add(new ColumnInfo(MetaField.CreateVirtual(this.Context, "eCF.50.Import", "SEO Title", "SeoTitle", "", MetaDataType.NVarChar, 150, true, false, true, false, false), fillTypes));
            array.Add(new ColumnInfo(MetaField.CreateVirtual(this.Context, "eCF.50.Import", "SEO Url", "SeoUrl", "", MetaDataType.NVarChar, 255, true, false, true, false, false), fillTypes));
            array.Add(new ColumnInfo(MetaField.CreateVirtual(this.Context, "eCF.50.Import", "SEO Description", "SeoDescription", "", MetaDataType.NVarChar, 355, true, false, true, false, false), fillTypes));
            array.Add(new ColumnInfo(MetaField.CreateVirtual(this.Context, "eCF.50.Import", "SEO Keywords", "SeoKeywords", "", MetaDataType.NVarChar, 355, true, false, true, false, false), fillTypes));
        }
Пример #22
0
        /// <summary>
        /// Gets the column.
        /// </summary>
        /// <param name="pageInstance">The page instance.</param>
        /// <param name="field">The field.</param>
        /// <param name="placeName">Name of the place.</param>
        /// <returns></returns>
        public DataControlField GetColumn(Page pageInstance, MetaField field, string placeName)
        {
            if (pageInstance == null)
            {
                throw new ArgumentNullException("pageInstance");
            }
            if (field == null)
            {
                throw new ArgumentNullException("field");
            }

            if (ControlPathResolver.Current == null)
            {
                throw new ArgumentNullException("ControlPathResolver");
            }

            if (pageInstance == null)
            {
                throw new ArgumentNullException("pageInstance");
            }

            TemplateField retVal = new TemplateField();

            ResolvedPath resPath = ControlPathResolver.Current.Resolve(CHelper.GetMetaTypeName(field), "Grid", field.Owner.Name, field.Name, placeName);

            if (resPath != null)
            {
                retVal.ItemTemplate = pageInstance.LoadTemplate(resPath.Path);
            }

            return(retVal);
        }
Пример #23
0
        protected override void Build()
        {
            var type = this.__CLRType;

            m_BuildInformation = new BuildInformation(type.Assembly, throwError: false);
            m_IsValueType      = type.IsValueType;
            m_IsVisible        = type.IsVisible;
            m_IsArray          = type.IsArray;
            m_IsAbstract       = type.IsAbstract;

            if (m_IsArray)
            {
                m_ArrayRank             = type.GetArrayRank();
                m_ArrayElementTypeIndex = MetaType.GetExistingOrNewMetaTypeIndex(m_Document, type.GetElementType());
            }

            m_Fields = new List <MetaField>();

            var fields = SerializationUtils.GetSerializableFields(type);

            foreach (var fld in fields)
            {
                var mf = new MetaField(this, fld);
                m_Fields.Add(mf);
                mf.m_Index = m_Fields.Count - 1;
            }

            m_MethodsOnSerializing = SerializationUtils.FindSerializationAttributedMethods(type, typeof(OnSerializingAttribute));
            m_MethodsOnSerialized  = SerializationUtils.FindSerializationAttributedMethods(type, typeof(OnSerializedAttribute));
        }
Пример #24
0
        private void MakeDataViewFromListForXML(DataTable dt, EntityObject[] list, string prefix)
        {
            DataRow dr;

            foreach (EntityObject entityObject in list)
            {
                dr = dt.NewRow();
                foreach (EntityObjectProperty entityProp in entityObject.Properties)
                {
                    EntityObject agregatedEntity = entityProp.Value as EntityObject;
                    if (agregatedEntity != null)                        //Aggregation
                    {
                        MakeDataViewFromListForXML(dt, new EntityObject[] { agregatedEntity }, entityProp.Name);
                    }
                    else
                    {
                        string metaFieldName = string.IsNullOrEmpty(prefix) ? entityProp.Name : String.Format("{0}.{1}", prefix, entityProp.Name);
                        if (dt.Columns.Contains(metaFieldName))
                        {
                            MetaField field = Mediachase.Ibn.Web.UI.Controls.Util.FormController.GetMetaField(ClassName, metaFieldName);
                            object    value = Mediachase.Ibn.Lists.Mapping.Type2McDataType.ConvertMcData2ManagedData(field, entityProp.Value);
                            if (value != null)
                            {
                                dr[metaFieldName] = value;
                            }
                        }
                    }
                }
                dt.Rows.Add(dr);
            }
        }
Пример #25
0
        private void AddMetaFieldLineItem(object sender, EventArgs eventArgs)
        {
            var lineItemMetaClass = OrderContext.Current.LineItemMetaClass;
            var context           = OrderContext.MetaDataContext;

            var name            = "VariantOptionCodes";
            var displayName     = "Variant Option Codes";
            var length          = 256;
            var metaFieldType   = MetaDataType.LongString;
            var metaNamespace   = string.Empty;
            var description     = string.Empty;
            var isNullable      = false;
            var isMultiLanguage = true;
            var isSearchable    = true;
            var isEncrypted     = true;

            var metaField = MetaField.Load(context, name) ?? MetaField.Create(context,
                                                                              lineItemMetaClass.Namespace,
                                                                              name,
                                                                              displayName,
                                                                              description,
                                                                              metaFieldType,
                                                                              length,
                                                                              isNullable,
                                                                              isMultiLanguage,
                                                                              isSearchable,
                                                                              isEncrypted);

            if (lineItemMetaClass.MetaFields.All(x => x.Id != metaField.Id))
            {
                lineItemMetaClass.AddField(metaField);
            }
        }
Пример #26
0
        private void ShowField(MetaField field)
        {
            field.Opacity = 1.0f;

            // If the field is a block, recursively set the opacity of its children
            var block = field as TagBlockData;

            if (block != null)
            {
                // Show wrappers
                _flattener.EnumWrappers(block, ShowField);

                // Show template fields
                foreach (MetaField child in block.Template)
                {
                    ShowField(child);
                }

                // Show modified fields
                foreach (TagBlockPage page in block.Pages)
                {
                    foreach (MetaField child in page.Fields)
                    {
                        if (child != null)
                        {
                            ShowField(child);
                        }
                    }
                }
            }
        }
Пример #27
0
            private MethodDeclarationSyntax CreateSingleElementMethod(MetaField field, IdentifierNameSyntax methodName, SimpleNameSyntax collectionMutationMethodName, bool passThroughChildSync = false)
            {
                var paramsArrayMethod = CreateMethodStarter(methodName.Identifier, field)
                                        .WithParameterList(SyntaxFactory.ParameterList(SyntaxFactory.SingletonSeparatedList(
                                                                                           SyntaxFactory.Parameter(ValueParameterName.Identifier).WithType(GetFullyQualifiedSymbolName(field.ElementType)))));

                var argument = passThroughChildSync
                    ? (ExpressionSyntax)SyntaxFactory.InvocationExpression(
                    Syntax.ThisDot(SyncImmediateChildToCurrentVersionMethodName),
                    SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument(ValueParameterName))))
                    : ValueParameterName;

                paramsArrayMethod = this.AddMethodBody(
                    paramsArrayMethod,
                    field,
                    receiver => SyntaxFactory.InvocationExpression(
                        SyntaxFactory.MemberAccessExpression(
                            SyntaxKind.SimpleMemberAccessExpression,
                            receiver,
                            collectionMutationMethodName),
                        SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(
                                                       SyntaxFactory.Argument(argument)))));

                return(paramsArrayMethod);
            }
Пример #28
0
 /// <summary>
 /// Binds the data.
 /// </summary>
 /// <param name="field">The field.</param>
 public void BindData(MetaField field)
 {
     ddlValue.Items.Clear();
     ddlValue.Items.Add(new ListItem(CHelper.GetResFileString(field.Attributes[McDataTypeAttribute.BooleanTrueText].ToString()), "true"));
     ddlValue.Items.Add(new ListItem(CHelper.GetResFileString(field.Attributes[McDataTypeAttribute.BooleanFalseText].ToString()), "false"));
     CHelper.SafeSelect(ddlValue, _value.ToString().ToLower());
 }
Пример #29
0
        private static List <MetaField> GetMetaFields(Type type)
        {
            var fields = type.GetFields();

            var result = new List <MetaField>();

            foreach (var field in fields)
            {
                string desc = "TODO document me";

                var attr = field.GetCustomAttribute <APIDescriptionAttribute>();
                if (attr != null)
                {
                    desc = attr.Description;
                }

                var meta = new MetaField()
                {
                    Name        = field.Name,
                    FieldType   = field.FieldType,
                    Description = desc
                };

                result.Add(meta);
            }

            return(result);
        }
 public void Initialize(MetaField field)
 {
     if (field.MemberType != typeof(double))
     {
         throw new ArgumentException("Only double member type is allowed.");
     }
 }
Пример #31
0
        public void Initialize(MetaField field)
        {
            Guard.CheckNotNull("field", field);

            if (field.AllowMultipleValues)
            {
                if (field.MemberType != typeof(TermInfo[]) &&
                    !field.MemberType.IsAssignableFrom(typeof(List <TermInfo>)))
                {
                    throw new ArgumentException("Only TermInfo[] or any class assigname from List<TermInfo> can be used as a member type.");
                }

                _isMulti = true;
                _isArray = field.MemberType.IsArray;
            }
            else
            {
                if (field.MemberType != typeof(TermInfo))
                {
                    throw new ArgumentException(
                              "Only TermInfo can be used as a member type.");
                }
            }

            _termSetId = field.TermSetId;
        }
Пример #32
0
        public void BindData(MetaField field)
        {
            string sReferencedClass = field.Attributes[McDataTypeAttribute.ReferenceMetaClassName].ToString();

            ViewState["ReferencedClass"] = sReferencedClass;
            if (sReferencedClass == TimeTrackingEntry.GetAssignedMetaClass().Name ||
                sReferencedClass == TimeTrackingBlock.GetAssignedMetaClass().Name ||
                sReferencedClass == TimeTrackingBlockType.GetAssignedMetaClass().Name ||
                sReferencedClass == TimeTrackingBlockTypeInstance.GetAssignedMetaClass().Name ||
                sReferencedClass == Principal.GetAssignedMetaClass().Name ||
                Mediachase.IBN.Business.Security.CurrentUser == null)
            {
                tblEntity.Visible = false;
                string url = ResolveClientUrl(String.Format("~/Apps/MetaUI/Pages/Public/SelectItem.aspx?class={0}&btn={1}", sReferencedClass, Page.ClientScript.GetPostBackEventReference(btnRefresh, "xxx")));

                ibSelect.OnClientClick = String.Format("OpenPopUpWindow(\"{0}\", 640, 480, 1); return false;", url);
            }
            else
            {
                ReferenceUpdatePanel.Visible = false;
                refObjects.ObjectTypes       = sReferencedClass;
                if (Request["ContainerFieldName"] != null &&
                    field.Name == Request["ContainerFieldName"] &&
                    Request["ContainerId"] != null)
                {
                    this.Value = PrimaryKeyId.Parse(Request["ContainerId"]);
                }
            }
        }
Пример #33
0
        private static void FastLoadField(MetaField fieldInfo, Pointer <byte> addr, Pointer <byte> fieldAddr)
        {
            int fieldSize = fieldInfo.Size;

            byte[] memCpy = addr.CopyBytes(fieldSize);
            fieldAddr.WriteAll(memCpy);
        }
Пример #34
0
 public void BindData(MetaField mf)
 {
     if (mf.Attributes.ContainsKey(McDataTypeAttribute.DateTimeMinValue))
         txtMinValue.Text = ((DateTime)mf.Attributes[McDataTypeAttribute.DateTimeMinValue]).ToString("yyyy-MM-dd");
     if (mf.Attributes.ContainsKey(McDataTypeAttribute.DateTimeMaxValue))
         txtMaxValue.Text = ((DateTime)mf.Attributes[McDataTypeAttribute.DateTimeMaxValue]).ToString("yyyy-MM-dd");
     chkCurrentDateAsDefault.Checked = (DefaultValue.Evaluate(mf) != null);
 }
 internal static ParameterListSyntax CreateParamsElementArrayParameters(MetaField field)
 {
     return SyntaxFactory.ParameterList(SyntaxFactory.SingletonSeparatedList(
          SyntaxFactory.Parameter(ValuesParameterName.Identifier)
                 .WithModifiers(SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.ParamsKeyword)))
                 .WithType(SyntaxFactory.ArrayType(GetFullyQualifiedSymbolName(field.ElementType))
                     .AddRankSpecifiers(SyntaxFactory.ArrayRankSpecifier(SyntaxFactory.SingletonSeparatedList<ExpressionSyntax>(SyntaxFactory.OmittedArraySizeExpression()))))));
 }
Пример #36
0
 public static bool CheckCardField(MetaClass _class, MetaField cardField)
 {
     string CardPKeyName = string.Format(CultureInfo.InvariantCulture, "{0}Id", cardField.Owner.Name);
     string CardRefKeyName = string.Format(CultureInfo.InvariantCulture, "{0}Id", _class.Name);
     return (cardField.Name != CardRefKeyName &&
             cardField.Name != CardPKeyName &&
             !(cardField.GetOriginalMetaType().McDataType == McDataType.ReferencedField &&
             cardField.Attributes.GetValue<string>(McDataTypeAttribute.ReferencedFieldMetaClassName) == _class.Name)
             );
 }
Пример #37
0
        public void BindData(MetaField mf)
        {
            if (mf.Attributes.ContainsKey(McDataTypeAttribute.StringMaxLength))
                txtMaxLen.Text = mf.Attributes[McDataTypeAttribute.StringMaxLength].ToString();
            txtMaxLen.Enabled = false;

            if (mf.Attributes.ContainsKey(McDataTypeAttribute.StringIsUnique))
                chkUnique.Checked = (bool)mf.Attributes[McDataTypeAttribute.StringIsUnique];
            chkUnique.Enabled = false;
        }
Пример #38
0
        public void BindData(MetaField mf)
        {
            if (mf.DefaultValue != String.Empty)
                txtDefaultValue.Text = ((decimal)DefaultValue.Evaluate(mf)).ToString("f");
            else
                txtDefaultValue.Text = "";

            if (mf.Attributes.ContainsKey(McDataTypeAttribute.CurrencyAllowNegative))
                chkAllowNegative.Checked = (bool)mf.Attributes[McDataTypeAttribute.CurrencyAllowNegative];
        }
Пример #39
0
        public void BindData(MetaField mf)
        {
            string RefClassName = mf.Attributes[McDataTypeAttribute.BackReferenceMetaClassName].ToString();
            string RefFieldName = mf.Attributes[McDataTypeAttribute.BackReferenceMetaFieldName].ToString();

            ddlClass.Items.Add(
              new ListItem(
                String.Format("{0} ({1})", RefClassName, RefFieldName),
                String.Format("{0},{1}", RefClassName, RefFieldName))
              );
            ddlClass.Enabled = false;
        }
Пример #40
0
        public void BindData(MetaField mf)
        {
            string primaryClassName = mf.Attributes[McDataTypeAttribute.ReferenceMetaClassName].ToString();
            ClassList.Items.Add(new ListItem(CHelper.GetResFileString(Mediachase.Ibn.Core.MetaDataWrapper.GetMetaClassByName(primaryClassName).FriendlyName)));
            ClassList.Enabled = false;

            chkUseObjectRoles.Enabled = false;
            chkUseObjectRoles.Checked = Mediachase.Ibn.Data.Services.Security.AreObjectRolesAddedFromRefernce(mf);

            if (!BusinessObjectServiceManager.IsServiceInstalled(mf.Owner, SecurityService.ServiceName))
                chkUseObjectRoles.Visible = false;
        }
Пример #41
0
        public void BindData(MetaField mf)
        {
            if (mf.Attributes.ContainsKey(McDataTypeAttribute.BooleanLabel))
                txtCheckBoxLabel.Text = mf.Attributes[McDataTypeAttribute.BooleanLabel].ToString();

            try
            {
                chkCheckedByDefault.Checked = (bool)DefaultValue.Evaluate(mf);
            }
            catch
            {
            }
        }
Пример #42
0
        public void BindData(MetaField mf)
        {
            if (mf.Attributes.ContainsKey(McDataTypeAttribute.StringMaxLength))
                txtMaxLen.Text = mf.Attributes[McDataTypeAttribute.StringMaxLength].ToString();
            txtMaxLen.Enabled = false;

            if (mf.Attributes.ContainsKey(McDataTypeAttribute.StringIsUnique))
                chkUnique.Checked = (bool)mf.Attributes[McDataTypeAttribute.StringIsUnique];
            chkUnique.Enabled = false;

            LoadData();
            if (mf.Attributes.ContainsKey(McDataTypeAttribute.StringUrlTarget))
                CHelper.SafeSelect(ddlTarget, mf.Attributes[McDataTypeAttribute.StringUrlTarget].ToString());
        }
 private void AddItem(MetaField mf)
 {
     if (mf.IsAggregation)
     {
         string aggrClassName = mf.Attributes[McDataTypeAttribute.AggregationMetaClassName].ToString();
         MetaClass mc = MetaDataWrapper.GetMetaClassByName(aggrClassName);
         foreach (MetaField mfa in mc.Fields)
             ddField.Items.Add(
                 new ListItem(
                     String.Format("{0} - {1}", CHelper.GetMetaFieldName(mf), CHelper.GetMetaFieldName(mfa)),
                     String.Format("{0}.{1}", mf.Name, mfa.Name)
                     )
                 );
     }
     else
         ddField.Items.Add(new ListItem(CHelper.GetMetaFieldName(mf), mf.Name));
 }
Пример #44
0
        public void BindData(MetaField mf)
        {
            string RefClassName = mf.Attributes[McDataTypeAttribute.ReferenceMetaClassName].ToString();
            string ReferenceName = mf.Attributes[McDataTypeAttribute.ReferencedFieldReferenceName].ToString();
            string RefFieldName = mf.Attributes[McDataTypeAttribute.ReferencedFieldMetaFieldName].ToString();

            MetaClass mc = MetaDataWrapper.GetMetaClassByName(RefClassName);

            ddlClass.Items.Add(
                new ListItem(
                    String.Format(CultureInfo.InvariantCulture, "{0} ({1})", CHelper.GetResFileString(mf.Owner.Fields[ReferenceName].FriendlyName), CHelper.GetResFileString(mc.FriendlyName)),
                    String.Format(CultureInfo.InvariantCulture, "{0},{1}", RefClassName, ReferenceName))
                );
            ddlClass.Enabled = false;

            ddlField.Items.Add(new ListItem(CHelper.GetResFileString(mc.Fields[RefFieldName].FriendlyName)));
            ddlField.Enabled = false;
        }
Пример #45
0
        public void BindData(MetaField mf)
        {
            if (mf.Attributes.ContainsKey(McDataTypeAttribute.FileNameRegexPattern))
                txtRegexPattern.Text = mf.Attributes[McDataTypeAttribute.FileNameRegexPattern].ToString();

            if (mf.Attributes.ContainsKey(McDataTypeAttribute.ImageWidth))
                txtWidth.Text = mf.Attributes[McDataTypeAttribute.ImageWidth].ToString();
            else
                txtWidth.Text = "";

            if (mf.Attributes.ContainsKey(McDataTypeAttribute.ImageHeight))
                txtHeight.Text = mf.Attributes[McDataTypeAttribute.ImageHeight].ToString();
            else
                txtHeight.Text = "";

            if (mf.Attributes.ContainsKey(McDataTypeAttribute.ImageShowBorder))
                chkShowBorder.Checked = (bool)mf.Attributes[McDataTypeAttribute.ImageShowBorder];
        }
Пример #46
0
        public void BindData(MetaField mf)
        {
            CultureInfo invariantCulture = new CultureInfo("");
            if (mf.Attributes.ContainsKey(McDataTypeAttribute.DoubleMinValue))
                txtMinValue.Text = ((double)mf.Attributes[McDataTypeAttribute.DoubleMinValue]).ToString("f");
            else
                txtMinValue.Text = "";

            if (mf.Attributes.ContainsKey(McDataTypeAttribute.DoubleMaxValue))
                txtMaxValue.Text = ((double)mf.Attributes[McDataTypeAttribute.DoubleMaxValue]).ToString("f");
            else
                txtMaxValue.Text = "";

            if (mf.DefaultValue != String.Empty)
                txtDefaultValue.Text = ((double)DefaultValue.Evaluate(mf)).ToString("f");
            else
                txtDefaultValue.Text = "";
        }
Пример #47
0
        public void BindData(MetaField mf)
        {
            ViewState[this.ClientID + "_TypeName"] = mf.TypeName;

            MetaFieldType mft = DataContext.Current.MetaModel.RegisteredTypes[mf.TypeName];

            trName.Visible = false;
            txtFriendlyName.Text = mft.FriendlyName;

            if (mf.Attributes.ContainsKey(McDataTypeAttribute.EnumEditable))
                chkEditable.Checked = (bool)mf.Attributes[McDataTypeAttribute.EnumEditable];

            if (mft.Attributes.ContainsKey(McDataTypeAttribute.EnumPrivate) &&
                mft.Attributes[McDataTypeAttribute.EnumPrivate].ToString() == mf.Owner.Name)
                chkPublic.Checked = false;
            else
                chkPublic.Checked = true;

            chkPublic.Enabled = false;
        }
Пример #48
0
        public void BindData(MetaField mf)
        {
            if (mf.Attributes.ContainsKey(McDataTypeAttribute.BooleanTrueText))
                txtYesText.Text = mf.Attributes[McDataTypeAttribute.BooleanTrueText].ToString();
            if (mf.Attributes.ContainsKey(McDataTypeAttribute.BooleanFalseText))
                txtNoText.Text = mf.Attributes[McDataTypeAttribute.BooleanFalseText].ToString();

            if (ddlDefaultValue.Items.Count == 0)
            {
                ddlDefaultValue.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.GlobalFieldManageControls", "Yes").ToString(), "1"));
                ddlDefaultValue.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.GlobalFieldManageControls", "No").ToString(), "0"));
            }

            try
            {
                if ((bool)DefaultValue.Evaluate(mf))
                    CHelper.SafeSelect(ddlDefaultValue, "1");
                else
                    CHelper.SafeSelect(ddlDefaultValue, "0");
            }
            catch
            {
            }
        }
Пример #49
0
        public DataControlField GetColumn(Page PageInstance, MetaField Field, bool IsPrimaryKey)
        {
            if (PageInstance == null)
                throw new ArgumentNullException("pageInstance");
            if (Field == null)
                throw new ArgumentNullException("field");

            TemplateField retVal = new TemplateField();

            if (!IsPrimaryKey)
            {
                string className = Field.Owner.Name;
                if (ListManager.MetaClassIsList(className))
                    className = "List_@";
                ResolvedPath resPath = ControlPathResolver.Current.Resolve(CHelper.GetMetaTypeName(Field), "GridEntity", className, Field.Name, viewName);

                if (resPath != null)
                    retVal.ItemTemplate = PageInstance.LoadTemplate(resPath.Path);
            }
            else
                retVal.ItemTemplate = PageInstance.LoadTemplate("~/Apps/MetaUIEntity/Primitives/Text.GridEntity.@[email protected]");

            return retVal;
        }
Пример #50
0
 public void BindData(MetaField field)
 {
     if (field.Attributes.ContainsKey(McDataTypeAttribute.StringMaxLength))
         txtValue.MaxLength = (int)field.Attributes[McDataTypeAttribute.StringMaxLength];
     if (field.Attributes.GetValue<bool>(McDataTypeAttribute.StringIsUnique, false))
         ViewState[FieldName + "FieldClassName"] = field.Owner.Name;
 }
Пример #51
0
 public void BindData(MetaField mf)
 {
 }
Пример #52
0
 public void BindData(MetaField mf)
 {
     txtMinValue.Text = mf.Attributes.GetValue<int>(McDataTypeAttribute.IntegerMinValue, int.MinValue).ToString();
     txtMaxValue.Text = mf.Attributes.GetValue<int>(McDataTypeAttribute.IntegerMaxValue, int.MaxValue).ToString();
     txtDefaultValue.Text = mf.DefaultValue;
 }
Пример #53
0
        /// <summary>
        /// Loads the request variables.
        /// </summary>
        private void LoadRequestVariables()
        {
            // Class
            if (Request.QueryString["class"] != null)
            {
                ClassName = Request.QueryString["class"];
                mc = MetaDataWrapper.GetMetaClassByName(ClassName);
            }

            // Bridge
            if (Request.QueryString["bridge"] != null)
            {
                BridgeName = Request.QueryString["bridge"];
                mcBridge = MetaDataWrapper.GetMetaClassByName(BridgeName);
            }

            // Current Field
            if (mcBridge != null && Request.QueryString["field"] != null)
            {
                FieldName = Request.QueryString["field"];
                mf = mcBridge.Fields[FieldName];
            }

            // Another field
            if (mf != null)
            {
                if (mf.Name == mcBridge.Attributes.GetValue<string>(MetaClassAttribute.BridgeRef1Name, string.Empty))
                    mfRef = mcBridge.Fields[mcBridge.Attributes[MetaClassAttribute.BridgeRef2Name].ToString()];
                else
                    mfRef = mcBridge.Fields[mcBridge.Attributes[MetaClassAttribute.BridgeRef1Name].ToString()];
            }

            // Another Class
            if (mfRef != null)
            {
                RefClassName = mfRef.Attributes.GetValue<string>(McDataTypeAttribute.ReferenceMetaClassName, string.Empty);
                if (!String.IsNullOrEmpty(RefClassName))
                    mcRef = MetaDataWrapper.GetMetaClassByName(RefClassName);
            }
        }
            private MethodDeclarationSyntax CreateParamsElementArrayMethod(MetaField field, IdentifierNameSyntax methodName, SimpleNameSyntax collectionMutationMethodName, bool passThroughChildSync = false)
            {
                var paramsArrayMethod = CreateMethodStarter(methodName.Identifier, field)
                    .WithParameterList(CreateParamsElementArrayParameters(field));

                var lambdaParameter = SyntaxFactory.Parameter(SyntaxFactory.Identifier("v"));
                var argument = passThroughChildSync
                    ? (ExpressionSyntax)Syntax.EnumerableExtension(
                        SyntaxFactory.IdentifierName(nameof(Enumerable.Select)),
                        ValuesParameterName,
                        SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(
                            SyntaxFactory.Argument(Syntax.ThisDot(SyncImmediateChildToCurrentVersionMethodName)))))
                    : ValuesParameterName;

                paramsArrayMethod = this.AddMethodBody(
                    paramsArrayMethod,
                    field,
                    receiver => SyntaxFactory.InvocationExpression(
                        SyntaxFactory.MemberAccessExpression(
                            SyntaxKind.SimpleMemberAccessExpression,
                            receiver,
                            collectionMutationMethodName),
                        SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(
                            SyntaxFactory.Argument(argument)))));

                return paramsArrayMethod;
            }
            private MethodDeclarationSyntax CreateSingleElementMethod(MetaField field, IdentifierNameSyntax methodName, SimpleNameSyntax collectionMutationMethodName, bool passThroughChildSync = false, IdentifierNameSyntax elementParameterName = null, ITypeSymbol elementType = null)
            {
                elementParameterName = elementParameterName ?? ValueParameterName;

                var paramsArrayMethod = CreateMethodStarter(methodName.Identifier, field)
                    .WithParameterList(SyntaxFactory.ParameterList(SyntaxFactory.SingletonSeparatedList(
                        SyntaxFactory.Parameter(elementParameterName.Identifier)
                        .WithType(GetFullyQualifiedSymbolName(elementType ?? field.ElementType)))));

                var argument = passThroughChildSync
                    ? (ExpressionSyntax)SyntaxFactory.InvocationExpression(
                        Syntax.ThisDot(SyncImmediateChildToCurrentVersionMethodName),
                        SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument(elementParameterName))))
                    : elementParameterName;

                paramsArrayMethod = this.AddMethodBody(
                    paramsArrayMethod,
                    field,
                    receiver => SyntaxFactory.InvocationExpression(
                        SyntaxFactory.MemberAccessExpression(
                            SyntaxKind.SimpleMemberAccessExpression,
                            receiver,
                            collectionMutationMethodName),
                        SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(
                            SyntaxFactory.Argument(argument)))));

                return paramsArrayMethod;
            }
            private MethodDeclarationSyntax CreateMethodStarter(SyntaxToken name, MetaField field)
            {
                var method = SyntaxFactory.MethodDeclaration(
                    GetFullyQualifiedSymbolName(this.generator.applyToSymbol),
                    name)
                    .AddModifiers(SyntaxFactory.Token(SyntaxKind.PublicKeyword));

                if (!field.IsLocallyDefined)
                {
                    method = Syntax.AddNewKeyword(method);
                }

                return method;
            }
            private MethodDeclarationSyntax CreateKeyValueMethod(MetaField field, IdentifierNameSyntax methodName, SimpleNameSyntax collectionMutationMethodName)
            {
                var paramsArrayMethod = CreateMethodStarter(methodName.Identifier, field)
                    .WithParameterList(SyntaxFactory.ParameterList(SyntaxFactory.SeparatedList(
                        new ParameterSyntax[] {
                            SyntaxFactory.Parameter(KeyParameterName.Identifier).WithType(GetFullyQualifiedSymbolName(field.ElementKeyType)),
                            SyntaxFactory.Parameter(ValueParameterName.Identifier).WithType(GetFullyQualifiedSymbolName(field.ElementValueType)),
                        })));

                paramsArrayMethod = this.AddMethodBody(
                    paramsArrayMethod,
                    field,
                    receiver => SyntaxFactory.InvocationExpression(
                        SyntaxFactory.MemberAccessExpression(
                            SyntaxKind.SimpleMemberAccessExpression,
                            receiver,
                            collectionMutationMethodName),
                        SyntaxFactory.ArgumentList(SyntaxFactory.SeparatedList(new ArgumentSyntax[] {
                            SyntaxFactory.Argument(KeyParameterName),
                            SyntaxFactory.Argument(ValueParameterName),
                        }))));

                return paramsArrayMethod;
            }
            private MemberDeclarationSyntax CreateClearMethod(MetaField field, IdentifierNameSyntax methodName)
            {
                var method = CreateMethodStarter(methodName.Identifier, field)
                    .WithParameterList(SyntaxFactory.ParameterList());

                method = this.AddMethodBody(
                    method,
                    field,
                    receiver => SyntaxFactory.InvocationExpression(
                        SyntaxFactory.MemberAccessExpression(
                            SyntaxKind.SimpleMemberAccessExpression,
                            receiver,
                            SyntaxFactory.IdentifierName(nameof(ICollection<int>.Clear))),
                        SyntaxFactory.ArgumentList()));

                return method;
            }
            private MethodDeclarationSyntax AddMethodBody(MethodDeclarationSyntax containingMethod, MetaField field, Func<ExpressionSyntax, InvocationExpressionSyntax> mutatingInvocationFactory)
            {
                var returnExpression = field.IsLocallyDefined
                    ? (ExpressionSyntax)SyntaxFactory.InvocationExpression( // this.With(field: this.field.SomeOperation(someArgs))
                        Syntax.ThisDot(WithMethodName),
                        SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(
                            SyntaxFactory.Argument(
                                SyntaxFactory.NameColon(field.Name),
                                NoneToken,
                                mutatingInvocationFactory(Syntax.ThisDot(field.NameAsField))))))
                    : SyntaxFactory.CastExpression( // (TemplateType)base.SameMethod(sameArgs)
                        GetFullyQualifiedSymbolName(this.generator.applyToSymbol),
                        SyntaxFactory.InvocationExpression(
                            Syntax.BaseDot(SyntaxFactory.IdentifierName(containingMethod.Identifier)),
                            SyntaxFactory.ArgumentList(
                                Syntax.JoinSyntaxNodes(
                                    SyntaxKind.CommaToken,
                                    containingMethod.ParameterList.Parameters.Select(p => SyntaxFactory.Argument(SyntaxFactory.IdentifierName(p.Identifier)))))));

                return containingMethod.WithBody(SyntaxFactory.Block(
                    SyntaxFactory.ReturnStatement(returnExpression)));
            }
Пример #60
0
        public void BindData(MetaField field)
        {
            string cards = String.Empty;
            int[] permittedTypes = (int[])field.Attributes[RoleTypeAttribute.PermittedPrincipalTypes];
            foreach (int i in permittedTypes)
            {
                if (!String.IsNullOrEmpty(cards))
                    cards += ",";

                //TODO DELEGATE
                //PrincipalTypes type = (PrincipalTypes)i;
                //cards += type.ToString();
            }

            MainPopupControl.CardFilter = cards;
        }