public async Task <IActionResult> Edit(long id, [Bind("Id,Type,InterfaceType,Name,Required,Direction,DontShow,Mask,Title,Comment,MinLength,MaxLength,RegExp,DontTicket")] ProviderField providerField)
        {
            if (id != providerField.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(providerField);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProviderFieldExists(providerField.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(providerField));
        }
示例#2
0
        private IEnumerable <KeyValuePair <TemplateKey, ProviderField> > ExtractFromTypes(Assembly a)
        {
            if (!AssemblyInfo.GetAssemblyInfo(a).ScanForTemplates)
            {
                yield break;
            }

            foreach (TypeInfo type in a.GetTypesHelper())
            {
                if (type.IsDefined(typeof(TemplatesAttribute)))
                {
                    foreach (FieldInfo field in type.GetFields())
                    {
                        if (!field.IsStatic)
                        {
                            continue;
                        }

                        if (typeof(ITemplate).IsAssignableFrom(field.FieldType))
                        {
                            var fieldResult = new ProviderField(field);
                            yield return(new KeyValuePair <TemplateKey, ProviderField>(fieldResult.Key, fieldResult));
                        }
                    }
                }
            }
        }
示例#3
0
        public void ReadXElement_Empty_ThrowsSyncDocumentException()
        {
            ProviderField field = new ProviderField();

            XElement element = XElement.Parse("<NotProviderField />");
            field.ReadXElement(element);
        }
        public void DefineProvider(QualifiedName name,
                                   Type providerType,
                                   FieldInfo field,
                                   object metadata = null)
        {
            if (providerType == null)
            {
                throw new ArgumentNullException("providerType");
            }
            if (field == null)
            {
                throw new ArgumentNullException("field");
            }
            if (!field.IsStatic ||
                !providerType.IsAssignableFrom(field.FieldType))
            {
                throw RuntimeFailure.InvalidProviderFieldOrMethod("field");
            }

            var qn          = GetName(name, field.DeclaringType, field.Name);
            var fieldResult = new ProviderField(field, providerType, qn);

            fieldResult.ProviderMetadata        = ProviderMetadataWrapper.Create(metadata);
            fieldResult.ProviderMetadata.Source = fieldResult;
            AppendResult(fieldResult);
        }
示例#5
0
        public void GetXElement_SetType_ReturnsCorrectXml()
        {
            ProviderField field = new ProviderField();
            field.Type = "System.Int32";

            var element = field.GetXElement();

            Assert.IsTrue(element.Attribute(ProviderField.CN_TYPE).Value == field.Type);
        }
示例#6
0
        public void GetXElement_SetName_ReturnsCorrectXml()
        {
            ProviderField field = new ProviderField();
            field.Name = "name1";

            var element = field.GetXElement();

            Assert.IsTrue(element.Attribute(ProviderField.CN_NAME).Value == field.Name);
        }
        public async Task <IActionResult> Create([Bind("Id,Type,InterfaceType,Name,Required,Direction,DontShow,Mask,Title,Comment,MinLength,MaxLength,RegExp,DontTicket")] ProviderField providerField)
        {
            if (ModelState.IsValid)
            {
                _context.Add(providerField);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(providerField));
        }
示例#8
0
        public ITemplate GetTemplate(Type templateType, QualifiedName name)
        {
            if (templateType == null)
            {
                throw new ArgumentNullException(nameof(templateType));
            }

            ProviderField f = _providers[new TemplateKey(templateType, name)];

            if (f == null)
            {
                return(null);
            }
            return((ITemplate)f.GetValue());
        }
示例#9
0
 public void PropertiesTest()
 {
     var vm = new ProviderField();
     TestsHelper.TestPublicPropertiesGetSet(vm, null, true);
 }
示例#10
0
 public static ProviderField Convert(Cebos.Veyron.ESync.SyncDocument.ProviderField field)
 {
     var result = new ProviderField {Name = field.Name, Type = field.Type};
     return result;
 }
        public void DefineProvider(QualifiedName name,
                                   Type providerType,
                                   FieldInfo field,
                                   object metadata = null)
        {
            if (providerType == null)
                throw new ArgumentNullException("providerType");
            if (field == null)
                throw new ArgumentNullException("field");
            if (!field.IsStatic
                || !providerType.IsAssignableFrom(field.FieldType)) {
                throw RuntimeFailure.InvalidProviderFieldOrMethod("field");
            }

            var qn = GetName(name, field.DeclaringType, field.Name);

            var fieldResult = new ProviderField(field, providerType, qn);
            fieldResult.Metadata = ProviderMetadataWrapper.Create(metadata);
            fieldResult.Metadata.Source = fieldResult;
            result.Add(fieldResult);
        }
示例#12
0
 public void ReadXElement_Empty_ThrowsArgumentNullException()
 {
     ProviderField field = new ProviderField();
     XElement element = null;
     field.ReadXElement(element);
 }