コード例 #1
0
 public MetadataDefinitionCreatedEvent(Guid aggregateIdentity, MetadataDefinitionName name, IDataType datatype, string regex)
     : base(aggregateIdentity)
 {
     Name = name;
     DataType = datatype.Tag;
     Regex = regex;
 }
コード例 #2
0
ファイル: ClassReader.cs プロジェクト: RobSmyth/nserializer
        public void ReadMembers(object instance, INXmlElementReader nodeReader, IDataType type)
        {
            using (var membersNodeReader = nodeReader.GetNextChildNode("members"))
            {
                if (membersNodeReader == null)
                {
                    throw new NXmlReaderFormatException("Missing class members node.");
                }

                ReadFields(instance, membersNodeReader, type);
            }

            var baseNodeReader = nodeReader.GetNextChildNode();
            if (baseNodeReader != null)
            {
                if (baseNodeReader.Name != "base")
                {
                    throw new NXmlReaderFormatException(
                        string.Format("Found a {0} node when expecting a base node.", baseNodeReader.Name));
                }

                using (var baseClassTypeNode = baseNodeReader.GetNextChildNode())
                {
                    baseClassMembersReader.ReadMembers(instance, baseClassTypeNode, type.BaseType);
                }

                baseNodeReader.Dispose();
            }
        }
コード例 #3
0
 public MetadataDefinitionState(MetadataDefinitionName name, IDataType datatype, string regex)
     : this(name,datatype)
 {
     _regex = regex;
     CreatedUtcDate = DateTime.UtcNow;
     IsDeleted = false;
 }
コード例 #4
0
 public ElementConstant(int position, IDataType dataType)
     : base(position)
 {
     this.dataType = dataType;
       Selectable = true;
       ElementType = ELEMENT_TYPE.CONSTANTE;
 }
コード例 #5
0
ファイル: EvaluationValue.cs プロジェクト: mingkongbin/anycmd
 /// <summary>
 /// Creates a new evaluation value specifying the data type.
 /// </summary>
 /// <param name="value">The value to hold in the evaluation value.</param>
 /// <param name="dataType">The data type for the value.</param>
 public EvaluationValue(object value, IDataType dataType)
 {
     if (dataType == null) throw new ArgumentNullException("dataType");
     var evaluationValue = value as EvaluationValue;
     if (evaluationValue != null)
     {
         _value = evaluationValue._value;
         _dataType = evaluationValue._dataType;
     }
     else if (value is BagValue)
     {
         _value = value;
         _dataType = dataType;
     }
     else
     {
         var parameter = value as IFunctionParameter;
         if (parameter != null)
         {
             _value = parameter.GetTypedValue(dataType, 0);
             _dataType = dataType;
         }
         else
         {
             _value = value;
             _dataType = dataType;
         }
     }
 }
コード例 #6
0
 public MetadataDefinitionState(MetadataDefinitionName name, IDataType datatype, IImmutableSet<AllowableValue> allowedValues, bool isDeleted)
     : this(name, datatype, allowedValues)
 {
     IsDeleted = isDeleted;
     CreatedUtcDate = DateTime.UtcNow;
     IsDeleted = false;
 }
コード例 #7
0
 public MetadataDefinitionState(MetadataDefinitionName name, IDataType datatype, string regex, IImmutableSet<AllowableValue> allowedValues)
     : this(name, datatype,regex)
 {
     _allowedValues = allowedValues;
     CreatedUtcDate = DateTime.UtcNow;
     IsDeleted = false;
 }
コード例 #8
0
 public MetadataDefinitionState(MetadataDefinitionName name, IDataType datatype, string regex, IImmutableSet<AllowableValue> allowedValues, MetadataDefinitionDescription desc, bool isDeleted)
     : this(name, datatype, regex, allowedValues)
 {
     _description = desc;
     CreatedUtcDate = DateTime.UtcNow;
     IsDeleted = isDeleted;
 }
コード例 #9
0
        private void ReadFields(object instance, INXmlElementReader membersNodeReader, IDataType type)
        {
            INXmlElementReader fieldReader;
            while ((fieldReader = membersNodeReader.GetNextChildNode("f")) != null)
            {
                if (fieldReader.Name != "f")
                {
                    throw new NXmlReaderFormatException(
                        string.Format("Invalid node '{0}' found when expecting a field node", fieldReader.Name));
                }

                try
                {
                    var members = memberReader.Read(fieldReader, type);
                    members.SetValue(instance);
                }
                catch (Exception exception)
                {
                    var memberName = fieldReader.Attributes.Get("name");
                    throw new NSerializerException(
                        string.Format("Error reading member '{0}.{1}", type.FullName, memberName),
                        exception);
                }

                fieldReader.Dispose();
            }
        }
コード例 #10
0
 public DataTypeValidationTest()
 {
     str = new DataTypeString();
       str.Value = "value";
       num = new DataTypeNumeric();
       num.Value = "4,12";
 }
コード例 #11
0
        void IBaseTypeMembersReader.ReadMembers(object instance, INXmlElementReader nodeReader, IDataType type)
        {
            var dictionary = (IDictionary) instance;

            using (var itemNodesReader = nodeReader.GetNextChildNode("items"))
            {
                var numberOfItemPairs = itemNodesReader.Attributes.GetInteger("count");
                for (var itemIndex = 0; itemIndex < numberOfItemPairs; itemIndex++)
                {
                    object key;
                    object value;

                    using (var keyReader = itemNodesReader.GetNextChildNode())
                    {
                        key = objectReader.Get(keyReader);
                    }

                    using (var valueReader = itemNodesReader.GetNextChildNode())
                    {
                        value = objectReader.Get(valueReader);
                    }

                    dictionary.Add(key, value);
                }
            }
        }
コード例 #12
0
ファイル: BagValue.cs プロジェクト: mingkongbin/anycmd
 /// <summary>
 /// Gets the value as a generic object.
 /// </summary>
 /// <param name="dataType">The expected data type of the value.</param>
 /// <param name="parNo">THe number of parameter used only for error notification.</param>
 /// <returns></returns>
 public object GetTypedValue(IDataType dataType, int parNo)
 {
     if (dataType != DataTypeDescriptor.Bag)
     {
         throw new EvaluationException("invalid datatype.");
     }
     return this;
 }
コード例 #13
0
 public EntityValueSetState(Guid metadataDefinitionIdentity, MetadataDefinitionName name, IDataType dataType, string regex, IValue supplied)
 {
     MetadataDefinitionIdentity = metadataDefinitionIdentity;
     Name = name;
     DataType = dataType;
     Regex = regex;
     Values = supplied;
 }
コード例 #14
0
 public EntityValueProvidedEvent(Guid aggregateIdentity, Guid metadataDefinitionIdentity, MetadataDefinitionName name, IDataType dataType, string regex, IValue value)
     : base(aggregateIdentity)
 {
     MetadataDefinitionIdentity = metadataDefinitionIdentity;
     Name = name;
     DataType = dataType;
     Regex = regex;
     Value = value;
 }
コード例 #15
0
 public MetadataDefinitionState(MetadataDefinitionName name, IDataType datatype)
 {
     _name = name;
     _datatype = datatype;
     _regex = String.Empty;
     _allowedValues = ImmutableHashSet.Create<AllowableValue>();
     CreatedUtcDate = DateTime.UtcNow;
     IsDeleted = false;
 }
コード例 #16
0
		public static void ClearAll()
		{
			AssemblyInspector = null;
			Connection = null;
			DataPopulation = null;
			DataType = null;
			DataSave = null;
			ObjectProperties = null;
			ClassProperties = null;

		}
コード例 #17
0
        /// <summary>
        /// Configures for DTG.
        /// </summary>
        /// <param name="dataType">Type of the data.</param>
        /// <param name="container">The container.</param>
        public static void ConfigureForDtg(IDataType dataType, Control container)
        {
            dataType.DataEditor.Editor.Load += (sender, args) =>
                {
                    var wmd = dataType.DataEditor.Editor.Controls[0];
                    wmd.ID = dataType.DataEditor.Editor.ID + "_ctl0";

                    var txt = (TextBox)wmd.Controls[0];
                    txt.ID = wmd.ID + "_ctl0";
                };
        }
コード例 #18
0
ファイル: factory.cs プロジェクト: KerwinMa/justEdit-
        /// <summary>
        /// Retrieve a complete list of all registered IDataType's
        /// </summary>
        /// <returns>A list of IDataType's</returns>
        public IDataType[] GetAll()
        {
            IDataType[] retVal = new IDataType[_controls.Count];
            int         c      = 0;

            foreach (Guid id in _controls.Keys)
            {
                retVal[c] = GetNewObject(id);
                c++;
            }

            return(retVal);
        }
コード例 #19
0
        public void Can_Perform_Get_On_DataTypeDefinitionRepository()
        {
            using (ScopeProvider.CreateScope())
            {
                // Act
                IDataType dataTypeDefinition = DataTypeRepository.Get(Constants.DataTypes.DropDownSingle);

                // Assert
                Assert.That(dataTypeDefinition, Is.Not.Null);
                Assert.That(dataTypeDefinition.HasIdentity, Is.True);
                Assert.That(dataTypeDefinition.Name, Is.EqualTo("Dropdown"));
            }
        }
コード例 #20
0
ファイル: DataTypeFactory.cs プロジェクト: swedishkid/umbraco
        public static DataTypeDto BuildDto(IDataType entity)
        {
            var dataTypeDto = new DataTypeDto
            {
                EditorAlias   = entity.EditorAlias,
                NodeId        = entity.Id,
                DbType        = entity.DatabaseType.ToString(),
                Configuration = ConfigurationEditor.ToDatabase(entity.Configuration),
                NodeDto       = BuildNodeDto(entity)
            };

            return(dataTypeDto);
        }
コード例 #21
0
        public ISchemaElementBuilder CreateElementWithValue(XName name, IDataType dataType, string description, Action <ISchemaElement> configurator = null)
        {
            var child = new SchemaElement(_schemaElement.Schema, name, description, _schemaElement)
            {
                UseContentAsValue = true,
                ValueType         = dataType
            };

            configurator?.Invoke(child);
            _schemaElement.AddChildElement(child);

            return(new SchemaElementBuilder(child));
        }
コード例 #22
0
        public void Different_Data_Editors_Returns_Different_Value_Editors()
        {
            var sut = new ValueEditorCache();

            var       dataEditor1 = new FakeDataEditor("Editor1");
            var       dataEditor2 = new FakeDataEditor("Editor2");
            IDataType dataType    = CreateDataTypeMock(1).Object;

            IDataValueEditor firstEditor  = sut.GetValueEditor(dataEditor1, dataType);
            IDataValueEditor secondEditor = sut.GetValueEditor(dataEditor2, dataType);

            Assert.AreNotSame(firstEditor, secondEditor);
        }
コード例 #23
0
        public IEnumerable <EntityContainer> GetContainers(IDataType dataType)
        {
            var ancestorIds = dataType.Path.Split(Constants.CharArrays.Comma, StringSplitOptions.RemoveEmptyEntries)
                              .Select(x =>
            {
                var asInt = x.TryConvertTo <int>();
                return(asInt ? asInt.Result : int.MinValue);
            })
                              .Where(x => x != int.MinValue && x != dataType.Id)
                              .ToArray();

            return(GetContainers(ancestorIds));
        }
コード例 #24
0
 protected bool TryResolveType(string typeName, out IDataType type)
 {
     if (typeName == null)
     {
         throw new ArgumentNullException("typeName");
     }
     if (typeName != string.Empty)
     {
         return(this.services.Binder.TryResolveType(typeName, out type));
     }
     type = null;
     return(false);
 }
コード例 #25
0
        internal DynamicReferenceInstance(IReferenceInstance refInstance) : base((IValueSymbol)refInstance)
        {
            this.normalizedDict = new Dictionary <string, ISymbol>(StringComparer.OrdinalIgnoreCase);
            IReferenceType  dataType = (IReferenceType)refInstance.DataType;
            IResolvableType type2    = (IResolvableType)dataType;

            this.resolvedReferenceType = (type2 == null) ? dataType : type2.ResolveType(DataTypeResolveStrategy.AliasReference);
            if (this.resolvedReferenceType.Category == DataTypeCategory.Struct)
            {
                ReadOnlySymbolCollection subSymbols = ((IReferenceInstanceAccess)refInstance).SubSymbols;
                this.normalizedDict = DynamicStructInstance.createMemberDictionary(false, subSymbols);
            }
        }
コード例 #26
0
        /// <summary>
        /// Deletes an <see cref="IDataType"/>
        /// </summary>
        /// <remarks>
        /// Please note that deleting a <see cref="IDataType"/> will remove
        /// all the <see cref="IPropertyType"/> data that references this <see cref="IDataType"/>.
        /// </remarks>
        /// <param name="dataType"><see cref="IDataType"/> to delete</param>
        /// <param name="userId">Optional Id of the user issuing the deletion</param>
        public void Delete(IDataType dataType, int userId = Cms.Core.Constants.Security.SuperUserId)
        {
            var evtMsgs = EventMessagesFactory.Get();
            using (var scope = ScopeProvider.CreateCoreScope())
            {
                var deletingDataTypeNotification = new DataTypeDeletingNotification(dataType, evtMsgs);
                if (scope.Notifications.PublishCancelable(deletingDataTypeNotification))
                {
                    scope.Complete();
                    return;
                }

                // find ContentTypes using this IDataTypeDefinition on a PropertyType, and delete
                // TODO: media and members?!
                // TODO: non-group properties?!
                var query = Query<PropertyType>().Where(x => x.DataTypeId == dataType.Id);
                var contentTypes = _contentTypeRepository.GetByQuery(query);
                foreach (var contentType in contentTypes)
                {
                    foreach (var propertyGroup in contentType.PropertyGroups)
                    {
                        var types = propertyGroup.PropertyTypes?.Where(x => x.DataTypeId == dataType.Id).ToList();
                        if (types is not null)
                        {
                            foreach (var propertyType in types)
                            {
                                propertyGroup.PropertyTypes?.Remove(propertyType);
                            }
                        }
                    }

                    // so... we are modifying content types here. the service will trigger Deleted event,
                    // which will propagate to DataTypeCacheRefresher which will clear almost every cache
                    // there is to clear... and in addition published snapshot caches will clear themselves too, so
                    // this is probably safe although it looks... weird.
                    //
                    // what IS weird is that a content type is losing a property and we do NOT raise any
                    // content type event... so ppl better listen on the data type events too.

                    _contentTypeRepository.Save(contentType);
                }

                _dataTypeRepository.Delete(dataType);

                scope.Notifications.Publish(new DataTypeDeletedNotification(dataType, evtMsgs).WithStateFrom(deletingDataTypeNotification));

                Audit(AuditType.Delete, userId, dataType.Id);

                scope.Complete();
            }
        }
コード例 #27
0
    protected override ActionResult <TreeNodeCollection> GetTreeNodes(string id, FormCollection queryStrings)
    {
        if (!int.TryParse(id, NumberStyles.Integer, CultureInfo.InvariantCulture, out var intId))
        {
            throw new InvalidOperationException("Id must be an integer");
        }

        var nodes = new TreeNodeCollection();

        //Folders first
        nodes.AddRange(
            _entityService.GetChildren(intId, UmbracoObjectTypes.DataTypeContainer)
            .OrderBy(entity => entity.Name)
            .Select(dt =>
        {
            TreeNode node = CreateTreeNode(dt, Constants.ObjectTypes.DataType, id, queryStrings,
                                           Constants.Icons.Folder, dt.HasChildren);
            node.Path     = dt.Path;
            node.NodeType = "container";
            // TODO: This isn't the best way to ensure a no operation process for clicking a node but it works for now.
            node.AdditionalData["jsClickCallback"] = "javascript:void(0);";
            return(node);
        }));

        //if the request is for folders only then just return
        if (queryStrings["foldersonly"].ToString().IsNullOrWhiteSpace() == false && queryStrings["foldersonly"] == "1")
        {
            return(nodes);
        }

        //System ListView nodes
        IEnumerable <int> systemListViewDataTypeIds = GetNonDeletableSystemListViewDataTypeIds();

        IEntitySlim[] children  = _entityService.GetChildren(intId, UmbracoObjectTypes.DataType).ToArray();
        var           dataTypes = _dataTypeService.GetAll(children.Select(c => c.Id).ToArray()).ToDictionary(dt => dt.Id);

        nodes.AddRange(
            children
            .OrderBy(entity => entity.Name)
            .Select(dt =>
        {
            IDataType dataType = dataTypes[dt.Id];
            TreeNode node      = CreateTreeNode(dt.Id.ToInvariantString(), id, queryStrings, dt.Name,
                                                dataType.Editor?.Icon, false);
            node.Path = dt.Path;
            return(node);
        })
            );

        return(nodes);
    }
コード例 #28
0
        /// <summary>
        /// Get data type by type name
        /// </summary>
        /// <param name="configuration">database configuration instance</param>
        /// <param name="name">data type name</param>
        /// <param name="size">size of data</param>
        /// <returns>data type instance</returns>
        public static IDataType GetDataType(this IDatabaseConfiguration configuration, string name, int?size = null)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            if (string.IsNullOrEmpty(name))
            {
                const string ErrorMessage = "parameter \"name\" should not be null or blank";
                Trace.TraceError(ErrorMessage);
                throw new ArgumentException(ErrorMessage);
            }

            IDataType dataType       = null;
            var       supportedTypes = configuration.SupportedTypes;

            if (supportedTypes.IsReadOnlyNullOrEmpty())
            {
                return(null);
            }

            if (!supportedTypes.TryGetValue(name, out dataType))
            {
                var errorMessage = string.Format(
                    CultureInfo.InvariantCulture,
                    "Type \"{0}\" is not supported",
                    name);
                Trace.TraceError(errorMessage);
                throw new ArgumentException(errorMessage);
            }

            var sizeType = dataType.DataSize.SizeType;

            if ((sizeType == DataSizeType.NotRequired) || ((sizeType == DataSizeType.Maximum) && !size.HasValue))
            {
                return(dataType);
            }

            if (!size.HasValue)
            {
                var errorMessage = string.Format(
                    CultureInfo.InvariantCulture,
                    "Data size of type \"{0}\" is required",
                    name);
                Trace.TraceError(errorMessage);
                throw new ArgumentException(errorMessage);
            }

            return(new DataType(dataType.TypeName, new DataSize(DataSizeType.Required, size)));
        }
コード例 #29
0
        public bool Implements(IDataType interfaceType)
        {
            var  name = interfaceType.FullName;
            bool ret;

            if (!_implements.TryGetValue(name, out ret))
            {
                _implements[name] = ret = _dataType.Implements(
                    interfaceType is CachingDataType
                                                ? ((CachingDataType)interfaceType)._dataType
                                                : interfaceType);
            }
            return(ret);
        }
コード例 #30
0
ファイル: StringValueBase.cs プロジェクト: mingkongbin/anycmd
        /// <summary>
        /// Returns the typed value for this string value.
        /// </summary>
        /// <param name="dataType">The expected data type of the value.</param>
        /// <param name="parNo">The parameter number used only for error reporing.</param>
        /// <returns>The typed value as an object.</returns>
        public object GetTypedValue(IDataType dataType, int parNo)
        {
            if (dataType == null) throw new ArgumentNullException("dataType");
            if (IsBag)
            {
                return this;
            }
            if (DataTypeValue != dataType.DataTypeName)
            {
                throw new EvaluationException(string.Format(Properties.Resource.exc_invalid_datatype_in_stringvalue, parNo, DataTypeValue));
            }

            return dataType.Parse(Value, parNo);
        }
コード例 #31
0
        public static IDataType RemoveDocTypeFromXPathFilter(this IDataType dataType, params string[] docTypes)
        {
            var preValues = dataType.GetMultiNodeTreePickerPreValues();

            var docTypeListXPath = new DocTypeListXPath(preValues.AllowedDocTypes);

            docTypeListXPath.Remove(docTypes);

            preValues.AllowedDocTypes = docTypeListXPath.ToString();

            dataType.SetMultiNodeTreePickerPreValues(preValues);

            return(dataType);
        }
コード例 #32
0
        internal static ISubRangeType Create(string name, IDataTypeResolver resolver)
        {
            string baseType = null;

            if (DataTypeStringParser.TryParseSubRange(name, out baseType))
            {
                IDataType type = null;
                if (resolver.TryResolveType(baseType, out type))
                {
                    Create(name, type);
                }
            }
            return(null);
        }
コード例 #33
0
ファイル: MemberReader.cs プロジェクト: RobSmyth/nserializer
        public IMemberValue Read(INXmlElementReader nodeReader, IDataType type)
        {
            var memberValues = new List<IMemberValue>();
            foreach (var typeMemberReader in memberReaders)
            {
                if (typeMemberReader.CanRead(nodeReader))
                {
                    memberValues.Add(typeMemberReader.Read(nodeReader, type));
                    break;
                }
            }

            return new MembersValue(memberValues.ToArray());
        }
コード例 #34
0
 internal Symbol(AdsSymbolEntry entry, IDataType type, ISymbol parent, ISymbolFactoryServices factoryServices) : this(entry, parent, factoryServices)
 {
     base.category         = type.Category;
     base.resolvedDataType = type;
     if ((base.attributes != null) && (base.attributes.Count >= 2))
     {
         ISubRangeType subRange = null;
         if (TryParseSubRange(type, base.attributes, factoryServices.Binder, out subRange))
         {
             base.category         = subRange.Category;
             base.resolvedDataType = subRange;
         }
     }
 }
コード例 #35
0
ファイル: EntityState.cs プロジェクト: brucewu16899/lacjam
        public EntityState AddOrUpdate(Guid metadataDefinitionIdentity, MetadataDefinitionName name, IDataType dataType, string regex, IValue supplied)
        {
            if (_values.All(x => x.MetadataDefinitionIdentity != metadataDefinitionIdentity))
                return new EntityState(_group, _name, _values.Add(new EntityValueSetState(metadataDefinitionIdentity, name, dataType, regex, supplied)));

            var element = _values.First(x => x.MetadataDefinitionIdentity == metadataDefinitionIdentity);

            element.Name = name;
            element.DataType = dataType;
            element.Regex = regex;
            element.Values = supplied;

            return this;
        }
コード例 #36
0
        public int Unmarshal(IAttributedInstance symbol, byte[] data, int offset, out object value)
        {
            Encoding encoding = null;

            EncodingAttributeConverter.TryGetEncoding(symbol.Attributes, out encoding);
            IDataType       dataType = symbol.DataType;
            IResolvableType type2    = symbol.DataType as IResolvableType;

            if (type2 != null)
            {
                dataType = type2.ResolveType(DataTypeResolveStrategy.AliasReference);
            }
            return(this._typeMarshaller.Unmarshal(dataType, encoding, data, offset, out value));
        }
コード例 #37
0
        public static bool IsAssignableTo(this IDataType type, string parentType)
        {
            var currentType = type;

            while (currentType != null)
            {
                if (currentType.Name == parentType)
                {
                    return(true);
                }
                currentType = type.BaseType;
            }
            return(false);
        }
コード例 #38
0
        public byte[] Marshal(IAttributedInstance symbol, object value)
        {
            Encoding encoding = null;

            this.TryGetEncoding(symbol, out encoding);
            IDataType       dataType = symbol.DataType;
            IResolvableType type2    = symbol.DataType as IResolvableType;

            if (type2 != null)
            {
                dataType = type2.ResolveType(DataTypeResolveStrategy.AliasReference);
            }
            return(this._typeMarshaller.Marshal(dataType, encoding, value));
        }
コード例 #39
0
ファイル: DataType.cs プロジェクト: Pravin044/TwinCat
        public IDataType ResolveType(DataTypeResolveStrategy type)
        {
            IDataType type2    = this;
            IDataType baseType = this;

            if (type == DataTypeResolveStrategy.Alias)
            {
                while (true)
                {
                    if ((baseType == null) || (baseType.Category != DataTypeCategory.Alias))
                    {
                        if ((baseType == null) && (this.Category == DataTypeCategory.Alias))
                        {
                            object[] args = new object[] { type2.Name };
                            Module.Trace.TraceWarning("Could not resolve Alias '{0}'", args);
                        }
                        break;
                    }
                    type2    = baseType;
                    baseType = ((IAliasType)baseType).BaseType;
                }
            }
            else if (type == DataTypeResolveStrategy.AliasReference)
            {
                while (true)
                {
                    if ((baseType == null) || ((baseType.Category != DataTypeCategory.Alias) && (baseType.Category != DataTypeCategory.Reference)))
                    {
                        if ((baseType == null) && ((this.Category == DataTypeCategory.Alias) || (this.Category == DataTypeCategory.Reference)))
                        {
                            object[] args = new object[] { type2.Name };
                            Module.Trace.TraceWarning("Could not resolve Alias/Reference '{0}'", args);
                        }
                        break;
                    }
                    if (baseType.Category == DataTypeCategory.Alias)
                    {
                        type2    = baseType;
                        baseType = ((IAliasType)baseType).BaseType;
                    }
                    else if (baseType.Category == DataTypeCategory.Reference)
                    {
                        type2    = baseType;
                        baseType = ((IReferenceType)baseType).ReferencedType;
                    }
                }
            }
            return(baseType);
        }
コード例 #40
0
        public void DefineMaps(IUmbracoMapper mapper)
        {
            mapper.Define <DocumentTypeSave, IContentType>(
                (source, context) => new ContentType(_shortStringHelper, source.ParentId), Map);
            mapper.Define <MediaTypeSave, IMediaType>(
                (source, context) => new MediaType(_shortStringHelper, source.ParentId), Map);
            mapper.Define <MemberTypeSave, IMemberType>(
                (source, context) => new MemberType(_shortStringHelper, source.ParentId), Map);

            mapper.Define <IContentType, DocumentTypeDisplay>((source, context) => new DocumentTypeDisplay(), Map);
            mapper.Define <IMediaType, MediaTypeDisplay>((source, context) => new MediaTypeDisplay(), Map);
            mapper.Define <IMemberType, MemberTypeDisplay>((source, context) => new MemberTypeDisplay(), Map);

            mapper.Define <PropertyTypeBasic, IPropertyType>(
                (source, context) =>
            {
                IDataType dataType = _dataTypeService.GetDataType(source.DataTypeId);
                if (dataType == null)
                {
                    throw new NullReferenceException("No data type found with id " + source.DataTypeId);
                }

                return(new PropertyType(_shortStringHelper, dataType, source.Alias));
            }, Map);

            // TODO: isPublishing in ctor?
            mapper.Define <PropertyGroupBasic <PropertyTypeBasic>, PropertyGroup>(
                (source, context) => new PropertyGroup(false), Map);
            mapper.Define <PropertyGroupBasic <MemberPropertyTypeBasic>, PropertyGroup>(
                (source, context) => new PropertyGroup(false), Map);

            mapper.Define <IContentTypeComposition, ContentTypeBasic>((source, context) => new ContentTypeBasic(), Map);
            mapper.Define <IContentType, ContentTypeBasic>((source, context) => new ContentTypeBasic(), Map);
            mapper.Define <IMediaType, ContentTypeBasic>((source, context) => new ContentTypeBasic(), Map);
            mapper.Define <IMemberType, ContentTypeBasic>((source, context) => new ContentTypeBasic(), Map);

            mapper.Define <DocumentTypeSave, DocumentTypeDisplay>((source, context) => new DocumentTypeDisplay(), Map);
            mapper.Define <MediaTypeSave, MediaTypeDisplay>((source, context) => new MediaTypeDisplay(), Map);
            mapper.Define <MemberTypeSave, MemberTypeDisplay>((source, context) => new MemberTypeDisplay(), Map);

            mapper.Define <PropertyGroupBasic <PropertyTypeBasic>, PropertyGroupDisplay <PropertyTypeDisplay> >(
                (source, context) => new PropertyGroupDisplay <PropertyTypeDisplay>(), Map);
            mapper.Define <PropertyGroupBasic <MemberPropertyTypeBasic>, PropertyGroupDisplay <MemberPropertyTypeDisplay> >(
                (source, context) => new PropertyGroupDisplay <MemberPropertyTypeDisplay>(), Map);

            mapper.Define <PropertyTypeBasic, PropertyTypeDisplay>((source, context) => new PropertyTypeDisplay(), Map);
            mapper.Define <MemberPropertyTypeBasic, MemberPropertyTypeDisplay>(
                (source, context) => new MemberPropertyTypeDisplay(), Map);
        }
コード例 #41
0
ファイル: MemberReader.cs プロジェクト: RobSmyth/nserializer
        public IMemberValue Read(INXmlElementReader nodeReader, IDataType type)
        {
            var memberValues = new List <IMemberValue>();

            foreach (var typeMemberReader in memberReaders)
            {
                if (typeMemberReader.CanRead(nodeReader))
                {
                    memberValues.Add(typeMemberReader.Read(nodeReader, type));
                    break;
                }
            }

            return(new MembersValue(memberValues.ToArray()));
        }
コード例 #42
0
        internal static ISubRangeType Create(AdsDataTypeEntry entry, IDataTypeResolver resolver)
        {
            ISubRangeType type     = null;
            string        baseType = null;

            if (DataTypeStringParser.TryParseSubRange(entry.entryName, out baseType))
            {
                IDataType type2 = null;
                if (resolver.TryResolveType(baseType, out type2))
                {
                    type = Create(entry.entryName, type2);
                }
            }
            return(type);
        }
コード例 #43
0
        public static IDataType SetMultiNodeTreePickerPreValues(this IDataType dataType, MultiNodeTreePickerPreValues multiNodeTreePickerPreValues)
        {
            if (dataType.GetDataTypePreValues().Any())
            {
                dataType.DeleteAllPreValues();
            }

            dataType.AddPreValue(multiNodeTreePickerPreValues.StartNode.ToJsonString(), 1, "startNode")
            .AddPreValue(multiNodeTreePickerPreValues.AllowedDocTypes, 2, "filter")
            .AddPreValue(multiNodeTreePickerPreValues.MinSelectedNodes.ToString(), 3, "minNumber")
            .AddPreValue(multiNodeTreePickerPreValues.MaxSelectedNodes.ToString(), 4, "maxNumber")
            .AddPreValue(multiNodeTreePickerPreValues.ShowEditButton ? "1" : "0", 5, "showEditButton");

            return(dataType);
        }
コード例 #44
0
        private void ProcessVariable(string fieldName, string typeInfo)
        {
            fieldName = Helper.CorrectHeadItemString(fieldName);

            string variableName = Helper.GetValidScriptVariableName(fieldName, true);

            if (variableName.Contains(CSVConstant.IDENTIFIER_OMIT_COLUMN))
            {
                return;
            }

            IDataType dataType = dataTypeFactory.GetDataType(typeInfo, fieldName);

            classWriter.ProcessVariable(fieldName, variableName, dataType);
        }
コード例 #45
0
ファイル: DbSqlite.cs プロジェクト: azanium/iShamelaV1-iOS
        public static string CreateDataTypesDefinition(IDataType[] vars)
        {
            string dt = "";
            for (int i = 0; i < vars.Count(); i++)
            {
                IDataType dataType = vars[i];
                dt = dt + dataType.AsString();
                if (i < vars.Count() - 1)
                {
                    dt = dt + ", ";
                }
            }

            return dt;
        }
コード例 #46
0
ファイル: rulezRepository.cs プロジェクト: boschn/otRulez
 /// <summary>
 /// adds a datatype to the repository by handle
 /// </summary>
 /// <param name="handle"></param>
 /// <param name="rule"></param>
 /// <returns></returns>
 public bool RemoveDataType(IDataType datatype)
 {
     Initialize();
     if (this.HasDataType(datatype.Name))
     {
         _datatypes.Remove(datatype.Name.ToUpper());
     }
     if (this.HasDataTypeSignature(datatype.Signature))
     {
         List <IDataType> aList = _datatypesSignature[datatype.Signature.ToUpper()];
         // remove all existing
         aList.RemoveAll(x => x.Name.ToUpper() == datatype.Name.ToUpper());
     }
     return(true);
 }
コード例 #47
0
        internal DynamicAliasInstance(IAliasInstance aliasInstance) : base((IValueSymbol)aliasInstance)
        {
            IAliasType      dataType = (IAliasType)aliasInstance.DataType;
            IResolvableType type2    = dataType as IResolvableType;

            this.resolvedAlias = (type2 == null) ? dataType : type2.ResolveType(DataTypeResolveStrategy.AliasReference);
            if (this.resolvedAlias.Category == DataTypeCategory.Struct)
            {
                this.normalizedDict = new Dictionary <string, ISymbol>(StringComparer.OrdinalIgnoreCase);
                foreach (DynamicSymbol symbol in base.SubSymbols)
                {
                    this.normalizedDict.Add(symbol.NormalizedName, symbol);
                }
            }
        }
コード例 #48
0
        private int tryReadValue(ISymbol symbol, int[] indices, out object result, out DateTime utcReadTime)
        {
            IDataType       dataType = symbol.DataType;
            IResolvableType type2    = dataType as IResolvableType;
            IArrayType      type3    = null;

            type3 = (type2 == null) ? ((IArrayType)dataType) : ((IArrayType)type2.ResolveType(DataTypeResolveStrategy.AliasReference));
            IDataType elementType = type3.ElementType;

            byte[] buffer = null;
            int    num    = this.TryReadArrayElementValue(symbol, indices, out buffer, out utcReadTime);

            result = (num != 0) ? null : base.valueFactory.CreateValue(symbol, buffer, 0, utcReadTime);
            return(num);
        }
コード例 #49
0
 private XElement SerializePropertyType(IPropertyType propertyType, IDataType definition, PropertyGroup propertyGroup)
 => new XElement("GenericProperty",
                 new XElement("Name", propertyType.Name),
                 new XElement("Alias", propertyType.Alias),
                 new XElement("Key", propertyType.Key),
                 new XElement("Type", propertyType.PropertyEditorAlias),
                 new XElement("Definition", definition.Key),
                 propertyGroup != null ? new XElement("Tab", propertyGroup.Name, new XAttribute("Alias", propertyGroup.Alias)) : null, // TODO Replace with PropertyGroupAlias
                 new XElement("SortOrder", propertyType.SortOrder),
                 new XElement("Mandatory", propertyType.Mandatory.ToString()),
                 new XElement("LabelOnTop", propertyType.LabelOnTop.ToString()),
                 propertyType.MandatoryMessage != null ? new XElement("MandatoryMessage", propertyType.MandatoryMessage) : null,
                 propertyType.ValidationRegExp != null ? new XElement("Validation", propertyType.ValidationRegExp) : null,
                 propertyType.ValidationRegExpMessage != null ? new XElement("ValidationRegExpMessage", propertyType.ValidationRegExpMessage) : null,
                 propertyType.Description != null ? new XElement("Description", new XCData(propertyType.Description)) : null);
コード例 #50
0
        public IActionResult Install()
        {
            var contentType = new ContentType(_shortStringHelper, -1)
            {
                Alias       = ContentAlias,
                Name        = "LoadTest Content",
                Description = "Content for LoadTest",
                Icon        = "icon-document"
            };
            IDataType def = _dataTypeService.GetDataType(TextboxDefinitionId);

            contentType.AddPropertyType(new PropertyType(_shortStringHelper, def)
            {
                Name        = "Origin",
                Alias       = "origin",
                Description = "The origin of the content.",
            });
            _contentTypeService.Save(contentType);

            Template containerTemplate = ImportTemplate(
                "LoadTestContainer",
                "LoadTestContainer",
                s_containerTemplateText);

            var containerType = new ContentType(_shortStringHelper, -1)
            {
                Alias         = ContainerAlias,
                Name          = "LoadTest Container",
                Description   = "Container for LoadTest content",
                Icon          = "icon-document",
                AllowedAsRoot = true,
                IsContainer   = true
            };

            containerType.AllowedContentTypes = containerType.AllowedContentTypes.Union(new[]
            {
                new ContentTypeSort(new Lazy <int>(() => contentType.Id), 0, contentType.Alias),
            });
            containerType.AllowedTemplates = containerType.AllowedTemplates.Union(new[] { containerTemplate });
            containerType.SetDefaultTemplate(containerTemplate);
            _contentTypeService.Save(containerType);

            IContent content = _contentService.Create("LoadTestContainer", -1, ContainerAlias);

            _contentService.SaveAndPublish(content);

            return(ContentHtml("Installed."));
        }
コード例 #51
0
        /// <summary>
        /// Deletes an <see cref="IDataType"/>
        /// </summary>
        /// <remarks>
        /// Please note that deleting a <see cref="IDataType"/> will remove
        /// all the <see cref="PropertyType"/> data that references this <see cref="IDataType"/>.
        /// </remarks>
        /// <param name="dataType"><see cref="IDataType"/> to delete</param>
        /// <param name="userId">Optional Id of the user issueing the deletion</param>
        public void Delete(IDataType dataType, int userId = 0)
        {
            using (var scope = ScopeProvider.CreateScope())
            {
                var deleteEventArgs = new DeleteEventArgs <IDataType>(dataType);
                if (scope.Events.DispatchCancelable(Deleting, this, deleteEventArgs))
                {
                    scope.Complete();
                    return;
                }


                // find ContentTypes using this IDataTypeDefinition on a PropertyType, and delete
                // fixme - media and members?!
                // fixme - non-group properties?!
                var query        = Query <PropertyType>().Where(x => x.DataTypeId == dataType.Id);
                var contentTypes = _contentTypeRepository.GetByQuery(query);
                foreach (var contentType in contentTypes)
                {
                    foreach (var propertyGroup in contentType.PropertyGroups)
                    {
                        var types = propertyGroup.PropertyTypes.Where(x => x.DataTypeId == dataType.Id).ToList();
                        foreach (var propertyType in types)
                        {
                            propertyGroup.PropertyTypes.Remove(propertyType);
                        }
                    }

                    // so... we are modifying content types here. the service will trigger Deleted event,
                    // which will propagate to DataTypeCacheRefresher which will clear almost every cache
                    // there is to clear... and in addition published snapshot caches will clear themselves too, so
                    // this is probably safe alghough it looks... weird.
                    //
                    // what IS weird is that a content type is losing a property and we do NOT raise any
                    // content type event... so ppl better listen on the data type events too.

                    _contentTypeRepository.Save(contentType);
                }

                _dataTypeRepository.Delete(dataType);

                deleteEventArgs.CanCancel = false;
                scope.Events.Dispatch(Deleted, this, deleteEventArgs);
                Audit(AuditType.Delete, userId, dataType.Id);

                scope.Complete();
            }
        }
コード例 #52
0
        /// <summary>
        /// Converts the datatype value to a DTG compatible string
        /// </summary>
        /// <param name="dataType">The DataType.</param>
        /// <returns></returns>
        public static string ToDtgString(IDataType dataType)
        {
            var value = dataType.Data.Value != null ? dataType.Data.Value.ToString() : string.Empty;

            try
            {
                var assembly = Assembly.GetAssembly(dataType.GetType());
                var type = assembly.GetType("Our.Umbraco.DataType.Markdown.XsltExtensions");

                return (string)type.InvokeMember("Transform", BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.Public, null, null, new object[] { value });
            }
            catch // (Exception ex)
            {
                return value;
                // TODO: [LK->OA] Did you want to capture the exception?
            }
        }
コード例 #53
0
ファイル: ListReader.cs プロジェクト: RobSmyth/nserializer
        void IBaseTypeMembersReader.ReadMembers(object instance, INXmlElementReader nodeReader, IDataType type)
        {
            var list = (IList) instance;

            using (var itemNodes = nodeReader.GetNextChildNode("items"))
            {
                var numberOfItems = itemNodes.Attributes.GetInteger("count");

                while (numberOfItems-- > 0)
                {
                    INXmlElementReader itemNode;
                    using (itemNode = itemNodes.GetNextChildNode())
                    {
                        list.Add(objectReader.Get(itemNode));
                    }
                }
            }
        }
コード例 #54
0
ファイル: FieldReader.cs プロジェクト: RobSmyth/nserializer
        public IMemberValue Read(INXmlElementReader nodeReader, IDataType type)
        {
            var fieldName = nodeReader.Attributes.Get("name");

            var field = type.GetField(fieldName);
            if (field == null)
            {
                throw new UnableToReadXMLTextException(
                    string.Format("Unable to find field '{0}'.", fieldName));
            }

            IMemberValue value;
            using (var valueNode = nodeReader.GetNextChildNode())
            {
                value = new FieldValue(field, objectReader.Get(valueNode));
            }

            return value;
        }
コード例 #55
0
 protected override System.Type MapDbType(string columnName, IDataType dataType)
 {
     switch (dataType.SqlType.ToLower())
     {
     case "float":
         return typeof(Double);
     case "integer":
         switch (dataType.Length)
         {
         case 1:
             return typeof(Byte);
         case 2:
             return typeof(Int16);
         case 4:
             return typeof(Int32);
         case 8:
             return typeof(Int64);
         }
         return MapDbType(columnName, null);
     default:
         return base.MapDbType(columnName, dataType);
     }
 }
コード例 #56
0
 /// <summary>
 /// Maps a type to enum type, if possible.
 /// </summary>
 /// <param name="dataType">Type of the data.</param>
 /// <returns></returns>
 protected virtual EnumType MapEnumDbType(IDataType dataType)
 {
     var enumType = new EnumType();
     // MySQL represents enums as follows:
     // enum('value1','value2')
     Match outerMatch = DefaultEnumDefinitionEx.Match(dataType.FullType);
     if (outerMatch.Success)
     {
         string values = outerMatch.Groups["values"].Value;
         var innerMatches = EnumValuesEx.Matches(values);
         int currentValue = 1;
         foreach (Match innerMatch in innerMatches)
         {
             var value = innerMatch.Groups["value"].Value;
             enumType.EnumValues[value] = currentValue++;
         }
     }
     return enumType;
 }
コード例 #57
0
        protected virtual Type MapDbType(string columnName, IDataType dataType)
        {
            if (dataType == null)
                throw new ArgumentNullException("dataType");
            if (dataType.ManagedType != null)
                return Type.GetType(dataType.ManagedType, true);

            string dataTypeL = dataType.SqlType.ToLowerInvariant();

            if (columnName != null && columnName.ToLower().Contains("guid"))
            {
                bool correctTypeAndLen =
                    ((dataTypeL == "char" || dataTypeL == "varchar") && dataType.Length == 36)
                    || ((dataTypeL == "binary") && dataType.Length == 16);

                if (correctTypeAndLen)
                {
                    Console.WriteLine("experimental support for guid--");
                    return typeof(Guid);
                }
            }

            switch (dataTypeL)
            {
            // string
            case "c":
            case "char":
            case "character":
            case "character varying":
            case "inet":
            case "long":
            case "longtext":
            case "long varchar":
            case "mediumtext":
            case "nchar":
            case "ntext":
            case "nvarchar":
            case "nvarchar2":
            case "string":
            case "text":
            case "varchar":
            case "varchar2":
            case "clob":    // oracle type
            case "nclob":   // oracle type
            case "rowid":   // oracle type
            case "urowid":  // oracle type
            case "tinytext": // mysql type
                return typeof(String);

            // bool
            case "bit":
            case "bool":
            case "boolean":
                return typeof(Boolean);

            // int8
            case "tinyint":
                if (dataType.Length == 1)
                    return typeof(Boolean);
                // tinyint is supposed to be signed
                // but we can have explicit sign
                if (dataType.Unsigned ?? false)
                    return typeof(Byte);
                // default case, unsigned
                return typeof(SByte);

            // int16
            case "short":
            case "smallint":
                if (dataType.Unsigned ?? false)
                    return typeof(UInt16);
                return typeof(Int16);

            // int32
            case "int":
            case "integer":
            case "mediumint":
                if (dataType.Unsigned ?? false)
                    return typeof(UInt32);
                return typeof(Int32);

            // int64
            case "bigint":
                return typeof(Int64);

            // single
            case "float":
            case "float4":
            case "real":
            case "binary_float":   // oracle type
                return typeof(Single);

            // double
            case "double":
            case "double precision":
            case "binary_double":  // oracle type
                return typeof(Double);

            // decimal
            case "decimal":
            case "money":
            case "numeric":
                return typeof(Decimal);
            case "number": // special oracle type
                if (dataType.Precision.HasValue && (dataType.Scale ?? 0) == 0)
                {
                    if (dataType.Precision.Value == 1)
                        return typeof(Boolean);
                    if (dataType.Precision.Value <= 4)
                        return typeof(Int16);
                    if (dataType.Precision.Value <= 9)
                        return typeof(Int32);
                    if (dataType.Precision.Value <= 19)
                        return typeof(Int64);
                }
                return typeof(Decimal);

            // time interval
            case "interval":
                return typeof(TimeSpan);

            //enum
            case "enum":
                return MapEnumDbType(dataType);

            // date
            case "date":
            case "datetime":
            case "ingresdate":
            case "timestamp":
            case "timestamp without time zone":
            case "time":
            case "time without time zone": //reported by [email protected],
            case "time with time zone":
                return typeof(DateTime);

            // byte[]
            case "binary":
            case "blob":
            case "bytea":
            case "byte varying":
            case "image":
            case "longblob":
            case "long byte":
            case "oid":
            case "sytea":
            case "mediumblob":
            case "tinyblob":
            case "raw":       // oracle type
            case "long raw":  // oracle type
            case "varbinary":
                return typeof(Byte[]);

            // PostgreSQL, for example has an uuid type that can be mapped as a Guid
            case "uuid":
                return typeof(Guid);

            case "void":
                return null;

            // if we fall to this case, we must handle the type
            default:
                throw new ArgumentException(
                    string.Format("Don't know how to convert the SQL type '{0}' into a managed type.", dataTypeL),
                    "dataType");
            }
        }
コード例 #58
0
ファイル: FirebirdSchemaLoader.cs プロジェクト: nlhepler/mono
        /// <summary>
        /// This is a hack while I figure out a way to produce Dialect 3 types.
        /// </summary>
        /// <param name="columnName"></param>
        /// <param name="dataType"></param>
        /// <returns></returns>
        protected override System.Type MapDbType(string columnName, IDataType dataType)
        {
            switch (dataType.SqlType)
            {
            // string
            case "CSTRING":
            case "TEXT":
            case "VARYING":
                return typeof(String);

            // int16
            case "SHORT":
                if (dataType.Unsigned ?? false)
                    return typeof(UInt16);
                return typeof(Int16);

            // int32
            case "LONG":
                if (dataType.Unsigned ?? false)
                    return typeof(UInt32);
                return typeof(Int32);

            // int64
            case "INT64":
                return typeof(Int64);

            // single
            case "FLOAT":
                return typeof(Single);

            // double
            case "DOUBLE":
                return typeof(Double);

            // decimal
            case "QUAD":
                return typeof(Decimal);

            // time interval
            case "TIME":
                return typeof(TimeSpan);

            // date
            case "TIMESTAMP":
            case "DATE":
                return typeof(DateTime);

            // byte[]
            case "BLOB":
            case "BLOB_ID":
                return typeof(Byte[]);

            // if we fall to this case, we must handle the type
            default:
                return null;
            }

        }
コード例 #59
0
 public MinLengthConstraint(ref DataTypeString data, int min)
 {
     _dataType = data;
       _min = min;
 }
コード例 #60
0
 public MinLengthConstraint(ref DataTypeNumeric data, int min)
 {
     _dataType = data;
       _min = min;
 }