Пример #1
0
 private String GetProperty(IPropertyType aProperty, Control aControl)
 {
     String result = aProperty.Get();
     result = result.Replace("$ControlClass", aControl.ControlClass());
     result = result.Replace("$ControlName", aControl.ControlName);
     return result;
 }
Пример #2
0
        public String AssignmentStatement(Control aControl, IPropertyType aProperty, String aValue)
        {
            String result = aProperty.Set();
            if (aValue.EndsWith(";"))
                aValue = aValue.Remove(aValue.Length - 1, 1);

            result = result.Replace("$ControlClass", aControl.ControlClass());
            result = result.Replace("$ControlName", aControl.ControlName);
            result = result.Replace("$Value", aValue);
            return result;
        }
Пример #3
0
        public PrefetchRule(IPropertyType propertyType, PrefetchPolicy prefetchPolicy)
        {
            if (propertyType == null)
            {
                throw new ArgumentNullException("propertyType");
            }

            if (prefetchPolicy != null)
            {
                var roleType = propertyType as IRoleType;
                if (roleType != null && roleType.ObjectType.IsUnit)
                {
                    throw new ArgumentException("prefetchPolicy");
                }
            }

            this.propertyType = propertyType;
            this.prefetchPolicy = prefetchPolicy;
        }
Пример #4
0
 public IProperty AddProperty(IPropertyType propertyType, string value)
 {
     return(null);
 }
Пример #5
0
 public PrefetchPolicyBuilder WithRule(IPropertyType propertyType, PrefetchPolicy prefetch)
 {
     var rule = new PrefetchRule(propertyType, prefetch);
     this.rules.Add(rule);
     return this;
 }
Пример #6
0
 public ContainedIn(IPropertyType propertyType = null) => this.PropertyType = propertyType;
Пример #7
0
 public bool HasProperty(IPropertyType propertyType)
 {
     return(false);
 }
Пример #8
0
        public static IEnumerable <ItemRow> GetItemRows(this IPropertiesContainer container, IPropertyType except = null)
        {
            IEnumerable <ItemRow> result = null;

            if (container is IThreatModelChild child && child.Model != null)
            {
                var model = child.Model;

                var schemas = GetSchemas(model, container.Properties)?.ToArray();

                if (schemas?.Any() ?? false)
                {
                    var list = new List <ItemRow>();

                    foreach (var schema in schemas)
                    {
                        var itemRows = container.Properties?
                                       .Where(x => !(x.PropertyType?.DoNotPrint ?? false) &&
                                              x.PropertyType.SchemaId == schema.Id &&
                                              x.PropertyType != except)
                                       .OrderBy(x => x.PropertyType?.Priority ?? 0)
                                       .Select(x => ItemRow.Create(container, x))
                                       .ToArray();

                        if (itemRows?.Any() ?? false)
                        {
                            list.AddRange(itemRows);
                        }
                    }

                    if (list.Any())
                    {
                        result = list;
                    }
                }
            }

            return(result);
        }
Пример #9
0
 public Exists(IPropertyType propertyType = null)
 {
     this.PropertyType = propertyType;
 }
Пример #10
0
 public Equals(IPropertyType propertyType = null)
 {
     this.PropertyType = propertyType;
 }
Пример #11
0
        private static bool CommandOverloadHasPropertyConformingBase(ICommandOverloadType derivedOverload, IPropertyType baseType, IErrorList errorList, ISource sourceLocation)
        {
            bool Result = true;

            if (derivedOverload.ParameterList.Count != 1 || derivedOverload.ParameterEnd != BaseNode.ParameterEndStatus.Closed)
            {
                errorList.AddError(new ErrorOverloadParameterMismatchConformance(sourceLocation, derivedOverload, baseType));
                Result = false;
            }

            if (derivedOverload.ParameterList.Count == 1)
            {
                IEntityDeclaration OverloadValue = derivedOverload.ParameterList[0];
                Debug.Assert(OverloadValue.ValidEntity.IsAssigned);
                Debug.Assert(OverloadValue.ValidEntity.Item.ResolvedEffectiveType.IsAssigned);

                Result &= TypeConformToBase(OverloadValue.ValidEntity.Item.ResolvedEffectiveType.Item, baseType.ResolvedEntityType.Item, errorList, sourceLocation, isConversionAllowed: false);
            }

            Result &= ExceptionListConformToBase(derivedOverload.ExceptionIdentifierList, baseType.SetExceptionIdentifierList, errorList, sourceLocation);

            return(Result);
        }
 private void OnPropertyTypeRemoved(IPropertySchema schema, IPropertyType propertyType)
 {
     RemoveProperty(propertyType);
 }
Пример #13
0
 /// <summary>
 /// Initialize a new instance of the <see cref="PublishedPropertyType"/> class with a property type.
 /// </summary>
 /// <remarks>
 /// <para>The new published property type belongs to the published content type.</para>
 /// </remarks>
 public PublishedPropertyType(IPublishedContentType contentType, IPropertyType propertyType, PropertyValueConverterCollection propertyValueConverters, IPublishedModelFactory publishedModelFactory, IPublishedContentTypeFactory factory)
     : this(propertyType.Alias, propertyType.DataTypeId, true, propertyType.Variations, propertyValueConverters, publishedModelFactory, factory)
 {
     ContentType = contentType ?? throw new ArgumentNullException(nameof(contentType));
 }
Пример #14
0
 public BlockPropertyValue(object?value, IPropertyType propertyType)
 {
     Value        = value;
     PropertyType = propertyType ?? throw new ArgumentNullException(nameof(propertyType));
 }
Пример #15
0
 public bool CanRead(IPropertyType propertyType) => this.IsPermitted(propertyType, Operations.Read);
Пример #16
0
 public bool IsCompressed(IReadOnlyContentBase content, IPropertyType propertyType, IDataEditor dataEditor, bool published) => false;
Пример #17
0
 public void AddProperty(IPropertyType Type, object Value)
 {
     this._properties[(PropertyType)Type] = new Property((PropertyType)Type, Value);
 }
Пример #18
0
 protected virtual bool IsTargetProperty(IPropertyType pt)   // [DAONET-56] (2007/08/29)
 {
     return(pt.PropertyInfo.CanWrite);
 }
Пример #19
0
 public APropertyUser(IPropertyType user, int reference)
 {
     _user          = user;
     _testReference = reference;
 }
Пример #20
0
 /// <summary>
 /// Constructor used to create a reference to a custom field.
 /// </summary>
 /// <param name="propertyType">Property Type for the custom field.</param>
 public IdentityField([NotNull] IPropertyType propertyType)
 {
     FieldType    = IdentityFieldType.Property;
     PropertyType = propertyType;
 }
Пример #21
0
        private static bool PropertyTypeConformToPropertyType(IPropertyType derivedType, IPropertyType baseType, IErrorList errorList, ISource sourceLocation)
        {
            bool Result = true;

            Debug.Assert(derivedType.ResolvedBaseType.IsAssigned);
            Debug.Assert(baseType.ResolvedBaseType.IsAssigned);

            Result &= TypeConformToBase(derivedType.ResolvedBaseType.Item, baseType.ResolvedBaseType.Item, errorList, sourceLocation, isConversionAllowed: false);

            if ((baseType.PropertyKind == BaseNode.UtilityType.ReadOnly && derivedType.PropertyKind == BaseNode.UtilityType.WriteOnly) ||
                (baseType.PropertyKind == BaseNode.UtilityType.WriteOnly && derivedType.PropertyKind == BaseNode.UtilityType.ReadOnly) ||
                (baseType.PropertyKind == BaseNode.UtilityType.ReadWrite && derivedType.PropertyKind != BaseNode.UtilityType.ReadWrite))
            {
                errorList.AddError(new ErrorGetterSetterConformance(sourceLocation, derivedType, baseType));
                Result = false;
            }

            Debug.Assert(derivedType.ResolvedEntityType.IsAssigned);
            Debug.Assert(baseType.ResolvedEntityType.IsAssigned);

            /*
             * if (!TypesHaveIdenticalSignature(derivedType.ResolvedEntityType.Item, baseType.ResolvedEntityType.Item))
             * {
             *  //errorList.Add(new ConformanceError(sourceLocation));
             *  return false;
             * }
             */

            Result &= TypeConformToBase(derivedType.ResolvedEntityType.Item, baseType.ResolvedEntityType.Item, errorList, sourceLocation, isConversionAllowed: false);
            Result &= ExceptionListConformToBase(derivedType.GetExceptionIdentifierList, baseType.GetExceptionIdentifierList, errorList, sourceLocation);
            Result &= ExceptionListConformToBase(derivedType.SetExceptionIdentifierList, baseType.SetExceptionIdentifierList, errorList, sourceLocation);

            return(Result);
        }
Пример #22
0
        private void AddReviewNotesPage([NotNull] PdfDocument doc, [NotNull] PdfStandardFont font,
                                        [NotNull] IEnumerable <IPropertiesContainer> containers, [NotNull] AnnotationsPropertySchemaManager schemaManager,
                                        [NotNull] IPropertyType propertyType)
        {
            string  objectType = null;
            string  name       = null;
            string  text       = null;
            Bitmap  image      = null;
            var     y          = 0f;
            PdfPage page       = null;
            var     textSize   = SizeF.Empty;

            foreach (var container in containers)
            {
                if (container is IDataFlow flow)
                {
                    objectType = _model.GetIdentityTypeName(flow);
                    name       = flow.Name;
                    text       = $"From {_model.GetIdentityTypeName(flow.Source)} '{flow.Source.Name}' to {_model.GetIdentityTypeName(flow.Target)} '{flow.Target.Name}'";
                    image      = flow.GetImage(ImageSize.Medium);
                }
                else if (container is IThreatEvent threatEvent)
                {
                    objectType = _model.GetIdentityTypeName(threatEvent);
                    name       = threatEvent.Name;
                    text       = $"Applied to {_model.GetIdentityTypeName(threatEvent.Parent)} '{threatEvent.Parent.Name}'";
                    image      = threatEvent.GetImage(ImageSize.Medium);
                }
                else if (container is IIdentity identity)
                {
                    objectType = _model.GetIdentityTypeName(identity);
                    name       = identity.Name;
                    text       = null;
                    image      = identity.GetImage(ImageSize.Medium);
                }
                else if (container is IThreatEventMitigation threatEventMitigation)
                {
                    objectType = "Threat Event Mitigation";
                    name       = threatEventMitigation.Mitigation.Name;
                    text       = $"Associated to Threat Event '{threatEventMitigation.ThreatEvent.Name}' on '{threatEventMitigation.ThreatEvent.Parent.Name}'";
                    image      = Icons.Resources.mitigations;
                }
                else if (container is IThreatTypeMitigation threatTypeMitigation)
                {
                    objectType = "Threat Type Mitigation";
                    name       = threatTypeMitigation.Mitigation.Name;
                    text       = $"Associated to Threat Type '{threatTypeMitigation.ThreatType.Name}'";
                    image      = Icons.Resources.standard_mitigations;
                }
                else
                {
                    objectType = null;
                    name       = null;
                    text       = null;
                    image      = null;
                }

                var reviewNotes = schemaManager.GetAnnotations(container)?.OfType <ReviewNote>().ToArray();
                if (reviewNotes?.Any() ?? false)
                {
                    PdfImage img;
                    foreach (var reviewNote in reviewNotes)
                    {
                        if (y == 0 || (y > page.Graphics.ClientSize.Height - textSize.Height * 10))
                        {
                            y    = 0;
                            page = doc.Pages.Add();

                            textSize = WriteText(page, "Review Notes", new PdfStandardFont(font, font.Size, PdfFontStyle.Bold), 0, 0);
                            y        = textSize.Height + 10;
                            page.Graphics.DrawLine(PdfPens.Black, 0, y, page.Graphics.ClientSize.Width, y);
                            y += 10;
                        }

                        if (image != null && objectType != null && name != null)
                        {
                            img = PdfImage.FromImage(image);
                            page.Graphics.DrawImage(img, new RectangleF(0, y, 16, 16));
                            textSize = WriteText(page, $"{objectType}: {name}", font, 18, y + 2);
                            if (text != null)
                            {
                                y       += textSize.Height + 5;
                                textSize = WriteText(page, text, font, 18, y);
                            }
                            y       += textSize.Height + 5;
                            textSize = WriteText(page, reviewNote.Text, font, 18, y);
                            y       += textSize.Height + 5;
                            textSize = WriteText(page, $"Note created by {reviewNote.CreatedBy} on {reviewNote.CreatedOn.ToShortDateString()} and modified by {reviewNote.ModifiedBy} on {reviewNote.ModifiedOn.ToShortDateString()}", font, 18, y);

                            y += textSize.Height + 10;
                        }
                    }
                }
            }
        }
Пример #23
0
        private static bool ProcedureTypeConformToPropertyType(IProcedureType derivedType, IPropertyType baseType, IErrorList errorList, ISource sourceLocation)
        {
            bool Result = true;

            Debug.Assert(derivedType.ResolvedBaseType.IsAssigned);
            Debug.Assert(baseType.ResolvedBaseType.IsAssigned);

            Result &= TypeConformToBase(derivedType.ResolvedBaseType.Item, baseType.ResolvedBaseType.Item, errorList, sourceLocation, isConversionAllowed: false);

            if (baseType.PropertyKind != BaseNode.UtilityType.WriteOnly)
            {
                errorList.AddError(new ErrorTypeKindConformance(sourceLocation, derivedType, baseType));
                Result = false;
            }

            IErrorList AllOverloadErrorList    = new ErrorList();
            bool       MatchingDerivedOverload = false;

            foreach (ICommandOverloadType DerivedOverload in derivedType.OverloadList)
            {
                IErrorList OverloadErrorList = new ErrorList();
                bool       IsMatching        = CommandOverloadHasPropertyConformingBase(DerivedOverload, baseType, OverloadErrorList, sourceLocation);
                if (!IsMatching)
                {
                    Debug.Assert(!OverloadErrorList.IsEmpty);
                    AllOverloadErrorList.AddError(OverloadErrorList.At(0));
                }

                MatchingDerivedOverload |= IsMatching;
            }

            if (!MatchingDerivedOverload)
            {
                errorList.AddErrors(AllOverloadErrorList);
                errorList.AddError(new ErrorTypeKindConformance(sourceLocation, derivedType, baseType));
                Result = false;
            }

            return(Result);
        }
Пример #24
0
 public PropertyTypeField([NotNull] IPropertyType propertyType)
 {
     PropertyType = propertyType;
 }
Пример #25
0
 private XElement SerializePropertyType(IPropertyType propertyType, IDataType?definition, PropertyGroup?propertyGroup)
 => new XElement("GenericProperty",
Пример #26
0
 public Property(string value, string name, IPropertyType type)
 {
     Type  = type;
     Name  = name;
     Value = value;
 }
Пример #27
0
 public Node(IPropertyType propertyType = null, Node[] nodes = null)
 {
     this.PropertyType = propertyType;
     this.Nodes        = nodes ?? new Node[0];
 }
 /// <inheritdoc />
 public IPublishedPropertyType CreatePropertyType(IPublishedContentType contentType, IPropertyType propertyType)
 {
     return(new PublishedPropertyType(contentType, propertyType, _propertyValueConverters, _publishedModelFactory, this));
 }
Пример #29
0
 public PropertyTypeValidationModel(IPropertyType propertyType, object?postedValue)
 {
     PostedValue  = postedValue;
     PropertyType = propertyType ?? throw new ArgumentNullException(nameof(propertyType));
 }
Пример #30
0
 /// <summary>
 /// Determines whether the property type varies by culture and segment.
 /// </summary>
 /// <param name="propertyType">The property type.</param>
 /// <returns>
 /// A value indicating whether the property type varies by culture and segment.
 /// </returns>
 public static bool VariesByCultureAndSegment(this IPropertyType propertyType) => propertyType.Variations.VariesByCultureAndSegment();
Пример #31
0
 public IProperty GetProperty(IPropertyType propertyType)
 {
     return(null);
 }
Пример #32
0
 /// <summary>
 /// Sets or removes the property type variation depending on the specified value.
 /// </summary>
 /// <param name="propertyType">The property type.</param>
 /// <param name="variation">The variation to set or remove.</param>
 /// <param name="value">If set to <c>true</c> sets the variation; otherwise, removes the variation.</param>
 /// <remarks>
 /// This method does not support setting the variation to nothing.
 /// </remarks>
 public static void SetVariesBy(this IPropertyType propertyType, ContentVariation variation, bool value = true) => propertyType.Variations = propertyType.Variations.SetFlag(variation, value);
Пример #33
0
 public bool RemoveProperty(IPropertyType propertyType)
 {
     return(false);
 }
Пример #34
0
 /// <summary>
 /// Determines whether the property type is invariant.
 /// </summary>
 /// <param name="propertyType">The property type.</param>
 /// <returns>
 /// A value indicating whether the property type is invariant.
 /// </returns>
 public static bool VariesByNothing(this IPropertyType propertyType) => propertyType.Variations.VariesByNothing();