internal static string Process(IPackageFile file, IPropertyProvider propertyProvider) { using (var stream = file.GetStream()) { return Process(stream, propertyProvider, throwIfNotFound: false); } }
public static Manifest ReadFrom(Stream stream, IPropertyProvider propertyProvider) { XDocument document; if (propertyProvider == NullPropertyProvider.Instance) { document = XDocument.Load(stream); } else { string content = Preprocessor.Process(stream, propertyProvider); document = XDocument.Parse(content); } string schemaNamespace = GetSchemaNamespace(document); foreach (var e in document.Descendants()) { // Assign the schema namespace derived to all nodes in the document. e.Name = XName.Get(e.Name.LocalName, schemaNamespace); } // Validate the schema ValidateManifestSchema(document, schemaNamespace); // Serialize it var manifest = ManifestReader.ReadManifest(document); // Validate before returning Validate(manifest); return manifest; }
public static string Process(Stream stream, IPropertyProvider propertyProvider, bool throwIfNotFound = true) { string text = stream.ReadToEnd(); var tokenizer = new Tokenizer(text); StringBuilder result = new StringBuilder(); for (; ; ) { Token token = tokenizer.Read(); if (token == null) { break; } if (token.Category == TokenCategory.Variable) { var replaced = ReplaceToken(token.Value, propertyProvider, throwIfNotFound); result.Append(replaced); } else { result.Append(token.Value); } } return result.ToString(); }
public static Manifest ReadFrom(Stream stream, IPropertyProvider propertyProvider, bool validateSchema) { XDocument document = XmlUtility.LoadSafe(stream, ignoreWhiteSpace: true); string schemaNamespace = GetSchemaNamespace(document); foreach (var e in document.Descendants()) { // Assign the schema namespace derived to all nodes in the document. e.Name = XName.Get(e.Name.LocalName, schemaNamespace); } // Validate if the schema is a known one CheckSchemaVersion(document); if (validateSchema) { // Validate the schema ValidateManifestSchema(document, schemaNamespace); } // Deserialize it var manifest = ManifestReader.ReadManifest(document); return manifest; }
public PackageBuilder(string path, string basePath, IPropertyProvider propertyProvider) : this() { using (Stream stream = File.OpenRead(path)) { ReadManifest(stream, basePath, propertyProvider); } }
internal static Type InferPropertyType(IPropertyProvider self, string property) { if (self.TryGetProperty(property, typeof(object), out object value)) { return(value == null ? typeof(object) : value.GetType()); } return(null); }
public PackageBuilder(string path, string basePath, IPropertyProvider propertyProvider, bool includeEmptyDirectories) : this(includeEmptyDirectories) { using (Stream stream = File.OpenRead(path)) { ReadManifest(stream, basePath, propertyProvider); } }
public static ulong GetUInt64(this IPropertyProvider source, string property) { if (source == null) { throw new ArgumentNullException("source"); } return(Convert.ToUInt64(source.GetProperty(property))); }
public PropertyItem GetProperty(IPropertyProvider propertyProvider, ProcessorItem item, string propertyName) { string filepath = item.Value; switch (propertyName) { case "name": return(new PropertyItem(Path.GetFileNameWithoutExtension(filepath))); case "ext": case "extension": return(new PropertyItem(Path.GetExtension(filepath).SafeSubstring(1))); case "filename": return(new PropertyItem(Path.GetFileName(filepath))); case "dir": case "directory": return(new PropertyItem(Path.GetDirectoryName(filepath))); case "value": return(new PropertyItem(item.Value)); case "ivalue": return(new PropertyItem(item.InitialValue)); case "mime": string mime = MimeTypesMap.GetMimeType(item.Value); return(new PropertyItem(mime)); case "relpath": PropertyItem originItem = item.GetProperty(propertyProvider, "origin"); if (originItem.IsNumeric || originItem == null) { return(null); } string origin = originItem.ValueText; if (!item.Value.StartsWith(origin)) { return(null); } return(new PropertyItem(item.Value.Substring(origin.Length + 1))); case "size": case "filesize": if (!File.Exists(item.Value)) { return(null); } long size = new FileInfo(item.Value).Length; return(new PropertyItem(size, null)); default: return(null); } }
public RouteValidator( IActionContextAccessor actionContextAccessor, IPropertyProvider propertyProvider, IMethodProvider methodProvider) { _actionContextAccessor = actionContextAccessor; _propertyProvider = propertyProvider; _methodProvider = methodProvider; }
private static string ReplaceToken(string propertyName, IPropertyProvider propertyProvider, bool throwIfNotFound) { var value = propertyProvider.GetPropertyValue(propertyName); if (value == null && throwIfNotFound) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, NuGetResources.TokenHasNoValue, propertyName)); } return value; }
public static T GetProperty <T>(this IPropertyProvider source, string property) { if (source == null) { throw new ArgumentNullException("source"); } return(source.GetProperty <T>(property, default(T))); }
public static void ClearDependencyBindings(this SDK.ContentObject source, IPropertyProvider properties) { var bindings = CreateBindings(source, properties); foreach (var binding in bindings.OfType <Bindings.DependencyBinding>()) { binding.ClearEvaluatedResult(); } }
private static string ReplaceToken(Match match, IPropertyProvider propertyProvider) { string propertyName = match.Groups["propertyName"].Value; var value = propertyProvider.GetPropertyValue(propertyName); if (value == null) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, NuGetResources.TokenHasNoValue, propertyName)); } return value; }
public static object GetProperty(this IPropertyProvider source, string property) { if (source == null) { throw new ArgumentNullException("source"); } return(source.GetProperty <object>(property, null)); }
/** * Adds a provider for virtual property values to the list. */ public void AttachPropertyProvider(IPropertyProvider provider) { if (_propertyProviders == null) { _propertyProviders = new ArrayList(); } _propertyProviders.Add(provider); provider.ResourceChanged += new PropertyProviderChangeEventHandler(provider_ResourceChanged); }
public static float GetSingle(this IPropertyProvider source, string property) { if (source == null) { throw new ArgumentNullException("source"); } return(Convert.ToSingle(source.GetProperty(property))); }
public GenericController(IGenericService <TModel, TSaveDto, TReadDto> genericService, IMapper mapper, IValidator validator, IPropertyProviderFactory propertyProviderFactory) { _genericService = genericService; _mapper = mapper; _validator = validator; _propertyProvider = propertyProviderFactory.Create(typeof(TPropertyProvider)); _propertiesToInclude = _propertyProvider.GetModelPropertiesToInclude().ToArray(); _propertyInfoList = _propertyProvider.GetReadDtoPropertiesToDisplay(); }
/// <summary> /// Task execution override /// </summary> /// <returns> /// True if successful /// False otherwise /// </returns> public override Boolean Execute() { try { // parepare the task for execution if (this.ReferenceLibraries == null) { this.ReferenceLibraries = new ITaskItem[0]; } if (!Path.IsPathRooted(this.OutputPath)) { this.OutputPath = Path.GetFullPath(this.OutputPath); } propertyProvider = new PropertyProvider(ProjectPath, this.ReferenceLibraries .ValidReferenceLibraryForBinaryNuSource() .ValidReferenceLibraryForPropertyProvider() .ToArray()); // add binary and NuBuild build dependencies to the list of sources this.sourceList.AddRange(this.ReferenceLibraries .ValidReferenceLibraryForBinaryNuSource()); this.sourceList.AddRange(this.ReferenceLibraries .ValidReferenceLibraryForNuBuildNuSource() .Select(referenceLibrary => new TaskItem(ProjectHelper.GetNupkgsFullPath( referenceLibrary.MSBuildSourceProjectFile(), Path.GetDirectoryName(referenceLibrary.FullPath()))))); // add build dependencies from the embedded resource file(s) this.sourceList.AddRange(this.Embedded); // parse the version source name this.versionSource = (VersionSource)Enum.Parse( typeof(VersionSource), this.VersionSource, true ); // configure each nuspec item (NuPackage will use the metadata added now) // it also adds the referred files in .nuspec files to the sources // and certainly adds the .nuspec files to sources and the .nupkg files to targets foreach (var specItem in this.NuSpec) { PreparePackage(specItem); } // add intermediate .nupkgs file to targets var nupkgsFullPath = ProjectHelper.GetNupkgsFullPath(ProjectPath, OutputPath); this.targetList.Add(new TaskItem(nupkgsFullPath)); // return the list of build sources/targets this.Prepared = this.preparedList.ToArray(); this.Sources = this.sourceList.ToArray(); this.Targets = this.targetList.ToArray(); } catch (Exception e) { Log.LogError("{0} ({1})", e.ToString(), e.GetType().Name); return(false); } return(true); }
public RouteFilterBuilder( IActionContextAccessor actionContextAccessor, IPropertyProvider propertyProvider, IMethodProvider methodProvider) { _actionContextAccessor = actionContextAccessor; _propertyProvider = propertyProvider; _methodProvider = methodProvider; }
public AppliedRuleBuilder(IVisualStyleProvider styleProvider, IDeclarationWorker declarationWorker, IPropertyProvider propertyProvider) { _styleProvider = styleProvider; StyleProvider = styleProvider; _declarationWorker = declarationWorker; _propertyProvider = propertyProvider; }
/// <summary> /// Creates a new IssueReportService with the default report backends (github and soon email) /// </summary> /// <param name="configuration"></param> /// <param name="stackTraceProvider"></param> public IssueReportService(IPropertyProvider configuration, IStackTraceProvider stackTraceProvider) { if (configuration == null) throw new ArgumentNullException("configuration"); _stackTraceProvider = stackTraceProvider; ActiveBackend = configuration.GetProperty("locco.backend"); RegisterKnownProviders(configuration); }
public static decimal GetDecimal(this IPropertyProvider source, string property) { if (source == null) { throw new ArgumentNullException("source"); } return(Convert.ToDecimal(source.GetProperty(property))); }
public StyledVisualWorker(IStyleSheet styleSheet, IPropertyProvider propertyProvider, IVisualBootstrapper visualBootstrapper) { _propertyProvider = propertyProvider; _visualBootstrapper = visualBootstrapper; _rules = new List <IStyleRule>(styleSheet.Rules); //_declarationWorker = new DeclarationWorker(renderPositions, visualBootstrapper); }
public StyledVisualBuilder(IVisualBootstrapper visualBootstrapper, IVisualStyleProvider styleProvider, IPropertyProvider propertyProvider, IAppliedStyleBuilder appliedStyleBuilder) { _visualBootstrapper = visualBootstrapper; _styleProvider = styleProvider; _propertyProvider = propertyProvider; _appliedStyleBuilder = appliedStyleBuilder; }
private static string ReplaceToken(string propertyName, IPropertyProvider propertyProvider, bool throwIfNotFound) { var value = propertyProvider.GetPropertyValue(propertyName); if (value == null && throwIfNotFound) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, NuGetResources.TokenHasNoValue, propertyName)); } return(value); }
public QueryStringParser( IOptions <CoreOptions> options, IPropertyProvider propertyProvider, IParameterParserFactory parameterParserFactory) { _options = options.Value; _queryString = new QueryString(options.Value); _propertyProvider = propertyProvider; _parameterParserFactory = parameterParserFactory; }
public SetHeaderInitializer(string headerName, IPropertyProvider <TInput, THeader> provider) { if (headerName == null) { throw new ArgumentNullException(nameof(headerName)); } _headerName = headerName; _provider = provider; }
public bool Check(IOutput console, IPropertyProvider propertyProvider, IPropertyStore propertyStore, ProcessorItem item) { propertyProvider.Begin(); bool result = conditions.All(x => x.Evaluate(console, propertyProvider, propertyStore, item)); propertyProvider.End(); return(result); }
void IPropertyTransformSpecification <TResult, TInput> .Configure(ITransformBuilder <TResult, TInput> builder) { IPropertyProvider <TProperty, TInput> propertyProvider = GetPropertyProvider(builder); var property = builder.ImplementationType == typeof(TResult) ? Property : builder.ImplementationType.GetProperty(Property.Name); Build(builder, propertyProvider, property); }
public DependingTypeResolver( IBaseTypeReader baseTypeReader, IPropertyProvider propertyProvider, ITsDefaultTypeProvider defaultTypeProvider, ITsCollectionProvider collectionProvider) { _baseTypeReader = baseTypeReader; _propertyProvider = propertyProvider; _defaultTypeProvider = defaultTypeProvider; _collectionProvider = collectionProvider; }
public static bool GetBoolean(this IPropertyProvider source, string property) { if (source == null) { throw new ArgumentNullException("source"); } var value = source.GetProperty(property); return(Convert.ToBoolean(value)); }
public DelegatePropertyProvider(IPropertyProvider <TInput, TProperty> inputProvider, Func <TransformPropertyContext <TProperty, TInput>, Task <TProperty> > valueProvider) { if (inputProvider == null) { throw new ArgumentNullException(nameof(inputProvider)); } _inputProvider = inputProvider; _valueProvider = valueProvider; }
public static string Format(string format, IPropertyProvider propertyProvider) { if (string.IsNullOrEmpty(format)) { return(string.Empty); } var ppf = PropertyProviderFormat.Parse(format); return(ppf.Format(propertyProvider)); }
public BindingBuilder(ITypeInferrer typeInferrer, IPropertyProvider propertyProvider, IAssemblyList assemblies, IResourceBuilder resourceBuilder) { _typeInferrer = typeInferrer; _propertyProvider = propertyProvider; _assemblies = assemblies; _resourceBuilder = resourceBuilder; _cachedPropertyAccessors = new DoubleConcurrentDictionary <Type, String, IPropertyAccessor>(); }
public static IPropertyProviderExtension Extend(IPropertyProvider provider) { if (provider == null) throw new ArgumentNullException("provider"); // $NON-NLS-1 IPropertyProviderExtension ppe = provider as IPropertyProviderExtension; if (ppe == null) return new PropertyProviderExtensionAdapter(provider); else return ppe; }
private static string ReplaceToken(Match match, IPropertyProvider propertyProvider) { string propertyName = match.Groups["propertyName"].Value; var value = propertyProvider.GetPropertyValue(propertyName); if (value == null) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, NuGetResources.TokenHasNoValue, propertyName)); } return(value); }
public static bool HasProperty(this IPropertyProvider source, string property) { if (source == null) { throw new ArgumentNullException("source"); } object dummy; return(source.TryGetProperty(property, out dummy)); }
public static IPropertyProvider Filter(IPropertyProvider propertyProvider, Func <string, bool> propertyFilter) { if (propertyProvider == null) { throw new ArgumentNullException(nameof(propertyProvider)); } if (propertyFilter == null) { throw new ArgumentNullException(nameof(propertyFilter)); } return(new FilterPropertyProvider(propertyProvider, propertyFilter)); }
private string m_InitialLocalPath; // - the path in the inventory that webdav operations operate // for example "/avatar/" or "/" public WebDAVPropertyHandler(WebDAVServerConnector connector, IInventoryService inventory_service, IAssetService asset_service, IPropertyProvider property_provider, WebDAVLockHandler lock_handler, string domain, string local_initial_path) { m_WebDAVServerConnector = connector; m_InventoryService = inventory_service; m_AssetService = asset_service; m_PropertyProvider = property_provider; m_SubDomain = domain; m_InitialLocalPath = local_initial_path; m_LockHandler = lock_handler; }
private static void LoadDataFromPropertiesDictionary(Settings settings, IPropertyProvider fields) { int incomleteOrderLifetime = 360; string stringValue = null; if (fields.UpdateValueIfPropertyPresent("incompleteOrderLifetime", ref stringValue)) { int.TryParse(stringValue, out incomleteOrderLifetime); } settings.IncompleteOrderLifetime = incomleteOrderLifetime; string property = null; fields.UpdateValueIfPropertyPresent("includingVat", ref property); settings.IncludingVat = property == "1" || property == "true"; fields.UpdateValueIfPropertyPresent("lowercaseUrls", ref property); settings.UseLowercaseUrls = property == "1" || property == "true"; }
public static Manifest ReadFrom(Stream stream, IPropertyProvider propertyProvider, bool validateSchema) { XDocument document; if (propertyProvider == NullPropertyProvider.Instance) { document = XmlUtility.LoadSafe(stream, ignoreWhiteSpace: true); } else { string content = Preprocessor.Process(stream, propertyProvider); document = XDocument.Parse(content); } string schemaNamespace = GetSchemaNamespace(document); foreach (var e in document.Descendants()) { // Assign the schema namespace derived to all nodes in the document. e.Name = XName.Get(e.Name.LocalName, schemaNamespace); } // Validate if the schema is a known one CheckSchemaVersion(document); if (validateSchema) { // Validate the schema ValidateManifestSchema(document, schemaNamespace); } // Deserialize it var manifest = ManifestReader.ReadManifest(document); // Validate before returning Validate(manifest); return manifest; }
public PropertyCopy(IPropertyProvider toCopy) { if (toCopy.StructuredProperties != null) foreach (var prop in toCopy.StructuredProperties) { AddStructuredProperty(prop.Key, prop.Value); } if (toCopy.UnstructuredProperties != null) foreach (var prop in toCopy.UnstructuredProperties) { AddUnstructuredProperty(prop.Key, prop.Value); } if (toCopy.UnknownProperties != null) foreach (var prop in toCopy.UnknownProperties) { AddUnknownProperty(prop.Key, prop.Value); } }
private static Dictionary<long, IComparable> ConvertStructuredProperties(IPropertyProvider myInsertDefinition, IBaseType myType) { return (myInsertDefinition.StructuredProperties == null) ? null : myInsertDefinition.StructuredProperties.ToDictionary(x => myType.GetAttributeDefinition(x.Key).ID, x => x.Value); }
private Tuple<long?, String, VertexUpdateDefinition> CreateVertexUpdateDefinition( IVertex myVertex, IVertexType myVertexType, RequestUpdate myUpdate, IPropertyProvider myPropertyCopy, Int64 myTransaction, SecurityToken mySecurity) { #region get removes List<long> toBeDeletedSingle = null; List<long> toBeDeletedHyper = null; List<long> toBeDeletedStructured = null; List<String> toBeDeletedUnstructured = null; List<long> toBeDeletedBinaries = null; if (myUpdate.RemovedAttributes != null) { #region remove each defined attribute foreach (var name in myUpdate.RemovedAttributes) { if (myVertexType.HasAttribute(name)) { var attr = myVertexType.GetAttributeDefinition(name); switch (attr.Kind) { case AttributeType.Property: if ((attr as IPropertyDefinition).IsMandatory) throw new MandatoryConstraintViolationException(attr.Name); toBeDeletedStructured = toBeDeletedStructured ?? new List<long>(); toBeDeletedStructured.Add(attr.ID); break; case AttributeType.BinaryProperty: toBeDeletedBinaries = toBeDeletedBinaries ?? new List<long>(); toBeDeletedBinaries.Add(attr.ID); break; case AttributeType.IncomingEdge: //TODO: a better exception here. throw new Exception("The edges on an incoming edge attribute can not be removed."); case AttributeType.OutgoingEdge: switch ((attr as IOutgoingEdgeDefinition).Multiplicity) { case EdgeMultiplicity.HyperEdge: case EdgeMultiplicity.MultiEdge: toBeDeletedHyper = toBeDeletedHyper ?? new List<long>(); toBeDeletedHyper.Add(attr.ID); break; case EdgeMultiplicity.SingleEdge: toBeDeletedSingle = toBeDeletedSingle ?? new List<long>(); toBeDeletedSingle.Add(attr.ID); break; default: //TODO a better exception here throw new Exception("The enumeration EdgeMultiplicity was changed, but not this switch statement."); } break; default: //TODO: a better exception here. throw new Exception("The enumeration AttributeType was updated, but not this switch statement."); } } else { toBeDeletedUnstructured = toBeDeletedUnstructured ?? new List<String>(); toBeDeletedUnstructured.Add(name); } } #endregion } if (myUpdate.RemovedUnstructuredProperties != null) { #region remove each unstructured property foreach (var name in myUpdate.RemovedUnstructuredProperties) { if ((myVertexType.HasAttribute(name)) && (myVertexType.GetAttributeDefinition(name).Kind == AttributeType.Property)) { toBeDeletedUnstructured = toBeDeletedUnstructured ?? new List<String>(); toBeDeletedUnstructured.Add(name); } } #endregion } #endregion #region get update definitions IDictionary<Int64, HyperEdgeUpdateDefinition> toBeUpdatedHyper = null; IDictionary<Int64, SingleEdgeUpdateDefinition> toBeUpdatedSingle = null; IDictionary<Int64, IComparable> toBeUpdatedStructured = null; IDictionary<String, Object> toBeUpdatedUnstructured = null; IDictionary<Int64, StreamAddDefinition> toBeUpdatedBinaries = null; long? revision = null; string edition = myUpdate.UpdatedEdition; string comment = myUpdate.UpdatedComment; #region property copy things if (myPropertyCopy.StructuredProperties != null) { toBeUpdatedStructured = new Dictionary<long, IComparable>(); foreach (var prop in myPropertyCopy.StructuredProperties) { var propDef = myVertexType.GetPropertyDefinition(prop.Key); CheckPropertyType(myVertexType.Name, prop.Value, propDef); toBeUpdatedStructured.Add(propDef.ID, prop.Value); } } toBeUpdatedUnstructured = myPropertyCopy.UnstructuredProperties; #endregion #region binary properties if (myUpdate.UpdatedBinaryProperties != null) { foreach (var prop in myUpdate.UpdatedBinaryProperties) { var propDef = myVertexType.GetBinaryPropertyDefinition(prop.Key); toBeUpdatedBinaries = toBeUpdatedBinaries ?? new Dictionary<long, StreamAddDefinition>(); toBeUpdatedBinaries.Add(propDef.ID, new StreamAddDefinition(propDef.ID, prop.Value)); } } #endregion #region collections if (myUpdate.AddedElementsToCollectionProperties != null || myUpdate.RemovedElementsFromCollectionProperties != null) { if (myUpdate.AddedElementsToCollectionProperties != null && myUpdate.RemovedElementsFromCollectionProperties != null) { var keys = myUpdate.AddedElementsToCollectionProperties.Keys.Intersect(myUpdate.RemovedElementsFromCollectionProperties.Keys); if (keys.CountIsGreater(0)) { //TOTO a better exception here throw new Exception("You can not add and remove items simultaneously on a collection attribute."); } if (myUpdate.AddedElementsToCollectionProperties != null) { foreach (var added in myUpdate.AddedElementsToCollectionProperties) { var propDef = myVertexType.GetPropertyDefinition(added.Key); var hasValue = (propDef == null) ? myVertex.HasUnstructuredProperty(added.Key) : myVertex.HasProperty(propDef.ID); //if it is not ICollectionWrapper something wrong with deserialization var extractedValue = (!hasValue) ? null : (propDef == null) ? myVertex.GetUnstructuredProperty<ICollectionWrapper>(added.Key) : (ICollectionWrapper)propDef.GetValue(myVertex); PropertyMultiplicity mult; if (propDef != null) { //check types only for structured properties foreach (var element in added.Value) { CheckPropertyType(myVertexType.Name, element, propDef); } mult = propDef.Multiplicity; } else mult = (added.Value is SetCollectionWrapper) ? PropertyMultiplicity.Set : PropertyMultiplicity.List; var newValue = CreateNewCollectionWrapper( (hasValue) ? extractedValue.Union(added.Value) : added.Value, mult); if (propDef == null) { toBeUpdatedUnstructured = toBeUpdatedUnstructured ?? new Dictionary<String, object>(); toBeUpdatedUnstructured.Add(added.Key, newValue); } else { toBeUpdatedStructured = toBeUpdatedStructured ?? new Dictionary<long, IComparable>(); toBeUpdatedStructured.Add(propDef.ID, newValue); } } } if (myUpdate.RemovedElementsFromCollectionProperties != null) { foreach (var remove in myUpdate.RemovedElementsFromCollectionProperties) { var propDef = myVertexType.GetPropertyDefinition(remove.Key); var hasValue = (propDef == null) ? myVertex.HasUnstructuredProperty(remove.Key) : myVertex.HasProperty(propDef.ID); //no value, nothing to remove if (!hasValue) continue; //if it is not ICollectionWrapper something wrong with deserialization var extractedValue = (propDef == null) ? myVertex.GetUnstructuredProperty<ICollectionWrapper>(remove.Key) : (ICollectionWrapper)propDef.GetValue(myVertex); PropertyMultiplicity mult = (propDef != null) ? propDef.Multiplicity : (extractedValue is SetCollectionWrapper) ? PropertyMultiplicity.Set : PropertyMultiplicity.List; var newValue = CreateNewCollectionWrapper(extractedValue.Except(remove.Value), mult); toBeUpdatedStructured.Add(propDef.ID, newValue); if (propDef == null) { toBeUpdatedUnstructured = toBeUpdatedUnstructured ?? new Dictionary<String, object>(); toBeUpdatedUnstructured.Add(remove.Key, newValue); } else { toBeUpdatedStructured = toBeUpdatedStructured ?? new Dictionary<long, IComparable>(); toBeUpdatedStructured.Add(propDef.ID, newValue); } } } } } #endregion #region extract vertex properties #region will be ignored long vertexID = 0L; long creationDate = 0L; long modificationDate = 0L; #endregion ExtractVertexProperties(ref edition, ref revision, ref comment, ref vertexID, ref creationDate, ref modificationDate, toBeUpdatedStructured); #endregion #region edge magic if (myUpdate.AddedElementsToCollectionEdges != null || myUpdate.RemovedElementsFromCollectionEdges != null || myUpdate.UpdateOutgoingEdges != null || myUpdate.UpdateOutgoingEdgesProperties != null) { VertexInformation source = new VertexInformation(myVertex.VertexTypeID, myVertex.VertexID); #region update outgoing edges if (myUpdate.UpdateOutgoingEdges != null) { foreach (var edge in myUpdate.UpdateOutgoingEdges) { var edgeDef = myVertexType.GetOutgoingEdgeDefinition(edge.EdgeName); switch (edgeDef.Multiplicity) { case EdgeMultiplicity.SingleEdge: { #region SingleEdge var targets = GetResultingVertexIDs(myTransaction, mySecurity, edge, edgeDef.TargetVertexType); if (targets == null || !targets.CountIsGreater(0)) { toBeDeletedSingle = toBeDeletedSingle ?? new List<long>(); toBeDeletedSingle.Add(edgeDef.ID); } else if (targets.CountIsGreater(1)) { throw new Exception("Single edge can not have more than one target."); } else { ConvertUnknownProperties(edge, edgeDef.EdgeType); var structured = CreateStructuredUpdate(edge.StructuredProperties, edgeDef.EdgeType); var unstructured = CreateUnstructuredUpdate(edge.UnstructuredProperties); toBeUpdatedSingle = toBeUpdatedSingle ?? new Dictionary<long, SingleEdgeUpdateDefinition>(); toBeUpdatedSingle.Add(edgeDef.ID, new SingleEdgeUpdateDefinition(source, targets.First(), edgeDef.EdgeType.ID, edge.Comment, structured, unstructured)); } #endregion } break; case EdgeMultiplicity.MultiEdge: { #region MultiEdge // Why deleting the edge instances ??? // they will never be inserted inside the update !!! // After delete the update will be needless because the edges are deleted !!! //List<SingleEdgeDeleteDefinition> internSingleDelete = null; //if (myVertex.HasOutgoingEdge(edgeDef.ID)) //{ // internSingleDelete = new List<SingleEdgeDeleteDefinition>(); // foreach (var edgeInstance in myVertex.GetOutgoingHyperEdge(edgeDef.ID).GetTargetVertices()) // { // internSingleDelete.Add( // new SingleEdgeDeleteDefinition(source, // new VertexInformation(edgeInstance.VertexTypeID, // edgeInstance.VertexID))); // } //} List<SingleEdgeUpdateDefinition> internSingleUpdate = null; var targets = GetResultingVertexIDs(myTransaction, mySecurity, edge, edgeDef.TargetVertexType); if (targets != null) { foreach (var target in targets) { internSingleUpdate = internSingleUpdate ?? new List<SingleEdgeUpdateDefinition>(); internSingleUpdate.Add(new SingleEdgeUpdateDefinition(source, target, edgeDef.InnerEdgeType.ID)); } } if (edge.ContainedEdges != null) { foreach (var innerEdge in edge.ContainedEdges) { targets = GetResultingVertexIDs(myTransaction, mySecurity, innerEdge, edgeDef.TargetVertexType); if (targets != null && targets.CountIsGreater(0)) { ConvertUnknownProperties(innerEdge, edgeDef.InnerEdgeType); var structured = CreateStructuredUpdate(innerEdge.StructuredProperties, edgeDef.InnerEdgeType); var unstructured = CreateUnstructuredUpdate(innerEdge.UnstructuredProperties); foreach (var target in targets) { internSingleUpdate = internSingleUpdate ?? new List<SingleEdgeUpdateDefinition>(); internSingleUpdate.Add( new SingleEdgeUpdateDefinition(source, target, edgeDef.InnerEdgeType.ID, innerEdge.Comment, structured, unstructured)); } } } } ConvertUnknownProperties(edge, edgeDef.EdgeType); var outerStructured = CreateStructuredUpdate(edge.StructuredProperties, edgeDef.EdgeType); var outerUnstructured = CreateUnstructuredUpdate(edge.UnstructuredProperties); toBeUpdatedHyper = toBeUpdatedHyper ?? new Dictionary<long, HyperEdgeUpdateDefinition>(); toBeUpdatedHyper.Add(edgeDef.ID, new HyperEdgeUpdateDefinition(edgeDef.EdgeType.ID, edge.Comment, outerStructured, outerUnstructured, null,//internSingleDelete, internSingleUpdate)); #endregion } break; case EdgeMultiplicity.HyperEdge: break; default: throw new Exception("The enumeration EdgeMultiplicity was changed, but not this switch statement."); } } } #endregion #region update outgoing edges properties if (myUpdate.UpdateOutgoingEdgesProperties != null) { foreach (var edge in myUpdate.UpdateOutgoingEdgesProperties) { var edgeDef = myVertexType .GetOutgoingEdgeDefinitions(true) .Where(_ => _.ID.Equals(edge.EdgeTypeID) || _.InnerEdgeType.ID.Equals(edge.EdgeTypeID)).FirstOrDefault(); switch (edgeDef.Multiplicity) { case EdgeMultiplicity.SingleEdge: { #region SingleEdge //var targets = GetResultingVertexIDs(myTransaction, mySecurity, edge, edgeDef.TargetVertexType); //if (targets == null || !targets.CountIsGreater(0)) //{ // toBeDeletedSingle = toBeDeletedSingle ?? new List<long>(); // toBeDeletedSingle.Add(edgeDef.ID); //} //else if (targets.CountIsGreater(1)) //{ // throw new Exception("Single edge can not have more than one target."); //} //else //{ // ConvertUnknownProperties(edge, edgeDef.EdgeType); // var structured = CreateStructuredUpdate(edge.StructuredProperties, edgeDef.EdgeType); // var unstructured = CreateUnstructuredUpdate(edge.UnstructuredProperties); // toBeUpdatedSingle = toBeUpdatedSingle ?? new Dictionary<long, SingleEdgeUpdateDefinition>(); // toBeUpdatedSingle.Add(edgeDef.ID, // new SingleEdgeUpdateDefinition(source, // targets.First(), // edgeDef.EdgeType.ID, // edge.Comment, // structured, // unstructured)); //} #endregion } break; case EdgeMultiplicity.MultiEdge: { #region MultiEdge List<SingleEdgeUpdateDefinition> internSingleUpdate = null; var targets = myVertex .GetOutgoingEdge(edgeDef.ID) .GetTargetVertices() .Select(_ => new VertexInformation(_.VertexTypeID, _.VertexID)); if (targets != null && targets.CountIsGreater(0)) { var structured = edge.UpdatedStructuredProperties; var unstructured = edge.UpdatedUnstructuredProperties; foreach (var target in targets) { internSingleUpdate = internSingleUpdate ?? new List<SingleEdgeUpdateDefinition>(); internSingleUpdate.Add( new SingleEdgeUpdateDefinition(source, target, edgeDef.InnerEdgeType.ID, edge.CommentUpdate, structured, unstructured)); } } toBeUpdatedHyper = toBeUpdatedHyper ?? new Dictionary<long, HyperEdgeUpdateDefinition>(); if (toBeUpdatedHyper.ContainsKey(edgeDef.ID)) { var temp = toBeUpdatedHyper[edgeDef.ID]; toBeUpdatedHyper.Remove(edgeDef.ID); toBeUpdatedHyper.Add(edgeDef.ID, MergeToBeAddedHyperEdgeUpdates(temp, internSingleUpdate)); } else toBeUpdatedHyper.Add(edgeDef.ID, new HyperEdgeUpdateDefinition(edgeDef.EdgeType.ID, null, null, null, null, internSingleUpdate)); #endregion } break; case EdgeMultiplicity.HyperEdge: break; default: throw new Exception("The enumeration EdgeMultiplicity was changed, but not this switch statement."); } } } #endregion #region update AddedElementsToCollectionEdges if (myUpdate.AddedElementsToCollectionEdges != null) { foreach (var hyperEdge in myUpdate.AddedElementsToCollectionEdges) { var edgeDef = myVertexType.GetOutgoingEdgeDefinition(hyperEdge.Key); if (edgeDef == null) //TODO a better exception here throw new Exception("edge attribute not defined."); if (edgeDef.Multiplicity == EdgeMultiplicity.SingleEdge) //TODO a better exception here throw new Exception("Add edges is only defined on hyper/multi edges."); var edgeTypeID = edgeDef.ID; StructuredPropertiesUpdate structuredUpdate; UnstructuredPropertiesUpdate unstructuredUpdate; IEnumerable<SingleEdgeUpdateDefinition> singleUpdate; CheckIfToBeAddedElementAlreadyExist(myVertex, edgeDef, hyperEdge.Value, myTransaction, mySecurity); CreateSingleEdgeUpdateDefinitions(source, myTransaction, mySecurity, hyperEdge.Value, edgeDef, out structuredUpdate, out unstructuredUpdate, out singleUpdate); toBeUpdatedHyper = toBeUpdatedHyper ?? new Dictionary<long, HyperEdgeUpdateDefinition>(); toBeUpdatedHyper.Add(edgeTypeID, new HyperEdgeUpdateDefinition(edgeTypeID, null, structuredUpdate, unstructuredUpdate, null, singleUpdate)); } } #endregion #region update RemovedElementsFromCollectionEdges if (myUpdate.RemovedElementsFromCollectionEdges != null) { foreach (var hyperEdge in myUpdate.RemovedElementsFromCollectionEdges) { var edgeDef = myVertexType.GetOutgoingEdgeDefinition(hyperEdge.Key); if (edgeDef == null) //TODO a better exception here throw new Exception("Edge attribute not defined."); if (edgeDef.Multiplicity == EdgeMultiplicity.SingleEdge) //TODO a better exception here throw new Exception("Removing edges is only defined on hyper/multi edges."); var edgeTypeID = edgeDef.ID; var del = CreateSingleEdgeDeleteDefinitions(source, myTransaction, mySecurity, hyperEdge.Value, edgeDef); toBeUpdatedHyper = toBeUpdatedHyper ?? new Dictionary<long, HyperEdgeUpdateDefinition>(); toBeUpdatedHyper.Add(edgeTypeID, new HyperEdgeUpdateDefinition(edgeTypeID, null, null, null, del, null)); } } #endregion } #endregion #region create updates var updateSingle = (toBeUpdatedSingle != null || toBeDeletedSingle != null) ? new SingleEdgeUpdate(toBeUpdatedSingle, toBeDeletedSingle) : null; var updateHyper = (toBeUpdatedHyper != null || toBeDeletedHyper != null) ? new HyperEdgeUpdate(toBeUpdatedHyper, toBeDeletedHyper) : null; var updateStructured = (toBeUpdatedStructured != null || toBeDeletedStructured != null) ? new StructuredPropertiesUpdate(toBeUpdatedStructured, toBeDeletedStructured) : null; var updateUnstructured = (toBeUpdatedUnstructured != null || toBeDeletedUnstructured != null) ? new UnstructuredPropertiesUpdate(toBeUpdatedUnstructured, toBeDeletedUnstructured) : null; var updateBinaries = (toBeUpdatedBinaries != null || toBeDeletedBinaries != null) ? new BinaryPropertiesUpdate(toBeUpdatedBinaries, toBeDeletedBinaries) : null; #endregion return Tuple.Create(revision, edition, new VertexUpdateDefinition(comment, updateStructured, updateUnstructured, updateBinaries, updateSingle, updateHyper)); }
private static void ConvertUnknownProperties(IPropertyProvider myPropertyProvider, IBaseType myBaseType) { if (myPropertyProvider.UnknownProperties != null) { foreach (var unknownProp in myPropertyProvider.UnknownProperties) { //ASK: What's about binary properties? if (myBaseType.HasProperty(unknownProp.Key)) { var propDef = myBaseType.GetPropertyDefinition(unknownProp.Key); try { var converted = unknownProp.Value.ConvertToIComparable(propDef.BaseType); myPropertyProvider.AddStructuredProperty(unknownProp.Key, converted); } catch (InvalidCastException) { //TODO: better exception throw new Exception("Type of property does not match."); } } else { myPropertyProvider.AddUnstructuredProperty(unknownProp.Key, unknownProp.Value); } } myPropertyProvider.ClearUnknown(); } }
public void SetPropertyProvider(IPropertyProvider provider) { }
/// <summary> /// Notify listeners that the value of an extension property has changed /// for a given instance. /// </summary> /// <param name="instance">The instance of the modified extended element.</param> /// <param name="provider">The <see cref="IPropertyProvider"/> instance that provides the modified property value.</param> /// <param name="descriptor">The property descriptor that was modified, or <see langword="null"/> to refresh all /// properties for the given provider.</param> public ExtensionPropertyChangedEventArgs(object instance, IPropertyProvider provider, PropertyDescriptor descriptor) { Instance = instance; Provider = provider; Descriptor = descriptor; }
public PackageBuilder(string path, IPropertyProvider propertyProvider) : this(path, Path.GetDirectoryName(path), propertyProvider) { }
public void SetPropertyProvider(IPropertyProvider provider) { _currentPropertyProvider = provider; _editor.Presentation.PropertyList.Provider = provider; }
/// <summary> /// Check for default values. /// If a default value is set for the property, than we add this to the insert definition. /// </summary> /// <param name="myPropertyProvider">The insert definition.</param> /// <param name="myBaseType">The vertex type, which is to be updated.</param> private static void ConvertDefaultValues(IPropertyProvider myPropertyProvider, IBaseType myBaseType) { if (myPropertyProvider.StructuredProperties != null) { var checkForDefaultValues = myBaseType.GetPropertyDefinitions(true).Where(item => !myPropertyProvider.StructuredProperties.ContainsKey(item.Name)).Where(_ => _.DefaultValue != null); foreach (var item in checkForDefaultValues) { myPropertyProvider.AddStructuredProperty(item.Name, item.DefaultValue); } } }
public PackageBuilder(string path, IPropertyProvider propertyProvider, bool includeEmptyDirectories) : this(path, Path.GetDirectoryName(path), propertyProvider, includeEmptyDirectories) { }
public ProviderInstance(IPropertyProvider provider) { myInstance = provider; myDelegate = null; }
void IPropertyProviderService.AddOrRemovePropertyProvider(Type extendableElementType, IPropertyProvider provider, bool includeSubtypes, EventHandlerAction action) { if ((object)provider == null) { throw new ArgumentNullException("provider"); } AddOrRemovePropertyProvider(extendableElementType, new ProviderInstance(provider), includeSubtypes, action); }
private void ReadManifest(Stream stream, string basePath, IPropertyProvider propertyProvider) { // Deserialize the document and extract the metadata Manifest manifest = Manifest.ReadFrom(stream, propertyProvider); Populate(manifest.Metadata); // If there's no base path then ignore the files node if (basePath != null) { if (manifest.Files == null) { AddFiles(basePath, @"**\*.*", null); } else { PopulateFiles(basePath, manifest.Files); } } }
public void ActivatePropertyProvider(IPropertyProvider provider) { }
public PackageBuilder(Stream stream, string basePath, IPropertyProvider propertyProvider) : this() { ReadManifest(stream, basePath, propertyProvider); }
public void ActivatePropertyProvider(IPropertyProvider provider) { _currentPropertyProvider = provider; _editor.Presentation.PropertyList.Provider = provider; _editor.ActivatePropertyPanel(); }
private void RegisterKnownProviders(IPropertyProvider configuration) { RegisterBackend(new GitHubProvider(configuration)); }