public FsuEngine(IOutput output) { Output = output; Tokenizer = new Tokenizer <TokenType>(TokenType.Invalid, TokenType.Eol, TokenType.Eof, false); Tokenizer.OnDefinitionAdded += (sender, definition) => { output.WriteLine(Level.Fine, $"Added Token: '&-e;{definition.Regex}&-^;' &-9;{definition.Precedence}&-^; (&-a;{definition.TokenType}&-^;)"); }; Parser = new TokenParser <TokenType, IProcessor>(TokenType.Comment, TokenType.Eol, TokenType.Eof, TokenType.Invalid); Parser.OnGrammarAdded += (sender, grammer) => { output.WriteLine(Level.Fine, $"Added Grammer: '&-b;{grammer.TriggerTokenValuePattern}&-^;' (&-a;{string.Join(", ", grammer.TriggerTokens)}&-^;) with {grammer.Rules.Count} rule(s)"); }; Parser.OnTokenError += (sender, token) => { output.WriteLine(Level.Error, $"&-c;ERROR - Unexpected token: '{token.Value}' ({token.TokenType}) {token.Location}&-^;"); }; Parser.OnTokenParsing += (sender, token) => { token.WriteLine(output, Level.Debug); }; interpreter = new Interpreter <TokenType, IProcessor>(Tokenizer, Parser); PropertyProviders = new PropertyProviderList(new BasicFilePropertyProvider()); PropertyStore = new PropertyStore(); Pipeline = new ProcessorPipeline(Output, PropertyProviders, PropertyStore, interpreter); Init(); }
public void GetEnumerator_will_merge_all_values() { var composite = PropertyStore.Compose( Properties.FromValue(new { a = "1", b = "2" }), Properties.FromValue(new { c = "1", d = "2" }) ); }
public void Delete(RouteValueDictionary values, object data) { object id = GetId(values, data); PropertyStore ps = PropertyStore.CreateFrom(data); Repository.Instance.Delete(data.GetType(), ps, id); }
/// <summary> /// Provide the property page with an array of pointers to objects associated /// with this property page. /// When the property page receives a call to IPropertyPage::Apply, it must send /// value changes to these objects through whatever interfaces are appropriate. /// The property page must query for those interfaces. This method can fail if /// the objects do not support the interfaces expected by the property page. /// </summary> /// <param name="cObjects"> /// The number of pointers in the array pointed to by ppUnk. /// If this parameter is 0, the property page must release any pointers previously /// passed to this method. /// </param> /// <param name="ppunk"></param> public void SetObjects(uint cObjects, object[] ppunk) { // If cObjects ==0 or ppunk == null, release the PropertyStore. if ((ppunk == null) || (cObjects == 0)) { if (PropertyStore != null) { PropertyStore.Dispose(); PropertyStore = null; } } else { // Initialize the PropertyStore using the provided objects. PropertyStore = GetNewPropertyStore(); PropertyStore.Initialize(ppunk); // If PropertyStore is not null, which means that the PageView UI has been // initialized, then it needs to be refreshed. if (PropertyStore != null) { MyPageView.RefreshPropertyValues(); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldProvideLabelScanStoreUpdatesSortedByNodeId() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldProvideLabelScanStoreUpdatesSortedByNodeId() { // GIVEN IndexingService indexing = mock(typeof(IndexingService)); when(indexing.ConvertToIndexUpdates(any(), eq(EntityType.NODE))).thenAnswer(o => Iterables.empty()); LabelScanWriter writer = new OrderVerifyingLabelScanWriter(10, 15, 20); WorkSync <System.Func <LabelScanWriter>, LabelUpdateWork> labelScanSync = spy(new WorkSync <System.Func <LabelScanWriter>, LabelUpdateWork>(SingletonProvider(writer))); WorkSync <IndexingUpdateService, IndexUpdatesWork> indexUpdatesSync = new WorkSync <IndexingUpdateService, IndexUpdatesWork>(indexing); TransactionToApply tx = mock(typeof(TransactionToApply)); PropertyStore propertyStore = mock(typeof(PropertyStore)); using (IndexBatchTransactionApplier applier = new IndexBatchTransactionApplier(indexing, labelScanSync, indexUpdatesSync, mock(typeof(NodeStore)), mock(typeof(RelationshipStore)), propertyStore, new IndexActivator(indexing))) { using (TransactionApplier txApplier = applier.StartTx(tx)) { // WHEN txApplier.VisitNodeCommand(Node(15)); txApplier.VisitNodeCommand(Node(20)); txApplier.VisitNodeCommand(Node(10)); } } // THEN all assertions happen inside the LabelScanWriter#write and #close verify(labelScanSync).applyAsync(any()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setUp() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void SetUp() { _life = new LifeSupport(); PageCache pageCache = Storage.pageCache(); DatabaseLayout databaseLayout = Storage.directory().databaseLayout(); Config config = Config.defaults(GraphDatabaseSettings.default_schema_provider, EMPTY.ProviderDescriptor.name()); NullLogProvider nullLogProvider = NullLogProvider.Instance; StoreFactory storeFactory = new StoreFactory(databaseLayout, config, new DefaultIdGeneratorFactory(Storage.fileSystem()), pageCache, Storage.fileSystem(), nullLogProvider, EmptyVersionContextSupplier.EMPTY); _neoStores = storeFactory.OpenAllNeoStores(true); _neoStores.Counts.start(); CountsComputer.recomputeCounts(_neoStores, pageCache, databaseLayout); _nodeStore = _neoStores.NodeStore; _relationshipStore = _neoStores.RelationshipStore; PropertyStore propertyStore = _neoStores.PropertyStore; JobScheduler scheduler = JobSchedulerFactory.createScheduler(); Dependencies dependencies = new Dependencies(); dependencies.SatisfyDependency(EMPTY); DefaultIndexProviderMap providerMap = new DefaultIndexProviderMap(dependencies, config); _life.add(providerMap); _indexingService = IndexingServiceFactory.createIndexingService(config, scheduler, providerMap, new NeoStoreIndexStoreView(LockService.NO_LOCK_SERVICE, _neoStores), SchemaUtil.idTokenNameLookup, empty(), nullLogProvider, nullLogProvider, IndexingService.NO_MONITOR, new DatabaseSchemaState(nullLogProvider), false); _propertyPhysicalToLogicalConverter = new PropertyPhysicalToLogicalConverter(_neoStores.PropertyStore); _life.add(_indexingService); _life.add(scheduler); _life.init(); _life.start(); _propertyCreator = new PropertyCreator(_neoStores.PropertyStore, new PropertyTraverser()); _recordAccess = new DirectRecordAccess <PropertyRecord, PrimitiveRecord>(_neoStores.PropertyStore, Loaders.propertyLoader(propertyStore)); }
private void CustomStorageTests() { NativeMethods.SetWindowProperty(this, "TestInt", 42); NativeMethods.SetWindowProperty(this, "TestLong", 123456789L); NativeMethods.SetWindowProperty(this, "TestString", "Hello World"); NativeMethods.SetWindowProperty(this, "TestSize", new Size(1, 2)); NativeMethods.SetWindowProperty(this, "TestPoint", new Point(12, 34)); NativeMethods.SetWindowProperty(this, "TestRect", new Rectangle(11, 22, 33, 44)); NativeMethods.SetWindowProperty(this, "TestColor", Color.Cyan); Debug.Assert(NativeMethods.GetWindowProperty(this, "TestInt", out int r1) && r1 == 42, "NativeMethods.GetWindowProperty[int]"); Debug.Assert(NativeMethods.GetWindowProperty(this, "TestLong", out long r2) && r2 == 123456789, "NativeMethods.GetWindowProperty[long]"); Debug.Assert(NativeMethods.GetWindowProperty(this, "TestString", out string r3) && r3 == "Hello World", "NativeMethods.GetWindowProperty[string]"); Debug.Assert(NativeMethods.GetWindowProperty(this, "TestSize", out Size r4) && r4 == new Size(1, 2), "NativeMethods.GetWindowProperty[Size]"); Debug.Assert(NativeMethods.GetWindowProperty(this, "TestPoint", out Point r5) && r5 == new Point(12, 34), "NativeMethods.GetWindowProperty[Point]"); Debug.Assert(NativeMethods.GetWindowProperty(this, "TestRect", out Rectangle r6) && r6 == new Rectangle(11, 22, 33, 44), "NativeMethods.GetWindowProperty[Rectangle]"); Debug.Assert(NativeMethods.GetWindowProperty(this, "TestColor", out Color r7) && r7 == Color.Cyan, "NativeMethods.GetWindowProperty[struct]"); NativeMethods.DisposeAllProperties(this); Debug.Assert(!NativeMethods.GetWindowProperty(this, "TestRect", out Rectangle r8)); int key1 = PropertyStore.CreateKey(); int key2 = PropertyStore.CreateKey(); int key3 = PropertyStore.CreateKey(); PropertyStore.SetInteger(this, key1, 42); PropertyStore.SetObject(this, key2, _tests[0]); PropertyStore.SetObject(this, key3, new KeyValuePair <string, int>("Hello", 42)); Debug.Assert(PropertyStore.GetInteger(this, key1) == 42, "PropertyStore.GetInteger[int]"); Debug.Assert(PropertyStore.GetObject(this, key2).Equals(_tests[0]), "PropertyStore.GetInteger[class]"); Debug.Assert(PropertyStore.GetObject(this, key3).Equals(new KeyValuePair <string, int>("Hello", 42)), "PropertyStore.GetInteger[struct]"); }
public void foobar() { var fooBytes = File.ReadAllBytes(@"C:\Temp\prop.bin"); var foo = new PropertyStore(fooBytes); Debug.WriteLine(foo); }
private void GetPropertyInformation() { IPropertyStore propstore; StorageAccessMode AccessMode = StorageAccessMode.Read; int msg = DeviceToUse.OpenPropertyStore(AccessMode, out propstore); PropStore = new PropertyStore(propstore); }
public DeleteDuplicateNodesStep(StageControl control, Configuration config, LongIterator nodeIds, NodeStore nodeStore, PropertyStore propertyStore, DataImporter.Monitor storeMonitor) : base(control, "DEDUP", config) { this._nodeStore = nodeStore; this._propertyStore = propertyStore; this._nodeIds = nodeIds; this._storeMonitor = storeMonitor; }
private static T WithName <T>(T record, int[] dynamicIds, string name) where T : Org.Neo4j.Kernel.impl.store.record.TokenRecord { if (dynamicIds == null || dynamicIds.Length == 0) { throw new System.ArgumentException("No dynamic records for storing the name."); } record.InUse = true; sbyte[] data = PropertyStore.encodeString(name); if (data.Length > dynamicIds.Length * NAME_STORE_BLOCK_SIZE) { throw new System.ArgumentException(string.Format("[{0}] is too long to fit in {1:D} blocks", name, dynamicIds.Length)); } else if (data.Length <= (dynamicIds.Length - 1) * NAME_STORE_BLOCK_SIZE) { throw new System.ArgumentException(string.Format("[{0}] is to short to fill {1:D} blocks", name, dynamicIds.Length)); } for (int i = 0; i < dynamicIds.Length; i++) { sbyte[] part = new sbyte[Math.Min(NAME_STORE_BLOCK_SIZE, data.Length - i * NAME_STORE_BLOCK_SIZE)]; Array.Copy(data, i * NAME_STORE_BLOCK_SIZE, part, 0, part.Length); DynamicRecord dynamicRecord = new DynamicRecord(dynamicIds[i]); dynamicRecord.InUse = true; dynamicRecord.Data = part; dynamicRecord.SetCreated(); record.addNameRecord(dynamicRecord); } record.NameId = dynamicIds[0]; return(record); }
public static T Get <T>(this IRepository repo, object id) where T : class, new() { PropertyStore ps = repo.Get(typeof(T), id); return(ps.Project <T>()); }
public override string ToString() { var sb = new StringBuilder(); if (PropertyStore != null) { if (PropertyStore.Sheets.Count > 0) { sb.AppendLine("Property Sheets"); sb.AppendLine(PropertyStore.ToString()); } } if (LastAccessTime.HasValue) { sb.AppendLine( $"Accessed On: {LastAccessTime.Value.ToString(Utils.GetDateTimeFormatWithMilliseconds())}"); sb.AppendLine(); } sb.AppendLine(base.ToString()); return(sb.ToString()); }
public static bool IsChanged <T>(this PropertyStore <T?> store) where T : struct => !((store.CurrentValue as IEquatable <T>)?.Equals(store.OriginalValue) ?? (store.OriginalValue as IEquatable <T>)?.Equals(store.CurrentValue) ?? store.CurrentValue?.Equals(store.OriginalValue) ?? store.OriginalValue?.Equals(store.CurrentValue) ?? true);
static void Main(string[] args) { var fooBytes = File.ReadAllBytes(@"C:\Temp\prop.bin"); var foo = new PropertyStore(fooBytes); Debug.WriteLine(foo); }
public override RecordGenerators_Generator <PropertyRecord> Property() { return((recordSize, format, recordId) => { PropertyRecord record = new PropertyRecord(recordId); int maxProperties = _random.intBetween(1, 4); StandaloneDynamicRecordAllocator stringAllocator = new StandaloneDynamicRecordAllocator(); StandaloneDynamicRecordAllocator arrayAllocator = new StandaloneDynamicRecordAllocator(); record.InUse = true; int blocksOccupied = 0; for (int i = 0; i < maxProperties && blocksOccupied < 4;) { PropertyBlock block = new PropertyBlock(); // Dynamic records will not be written and read by the property record format, // that happens in the store where it delegates to a "sub" store. PropertyStore.EncodeValue(block, _random.Next(_tokenBits), _random.nextValue(), stringAllocator, arrayAllocator, true); int tentativeBlocksWithThisOne = blocksOccupied + block.ValueBlocks.length; if (tentativeBlocksWithThisOne <= 4) { record.addPropertyBlock(block); blocksOccupied = tentativeBlocksWithThisOne; } } record.PrevProp = RandomLongOrOccasionallyNull(_propertyBits); record.NextProp = RandomLongOrOccasionallyNull(_propertyBits); return record; }); }
/// <summary> /// Decollates changes to content object which should be redirected to other records used as property sources /// </summary> /// <param name="path">path of content record</param> /// <param name="data">content object</param> /// <returns>JObject build from content object</returns> protected virtual JObject SetRelated(string path, object data) { // Establish the records to fetch and fetch them Type contentType = data.GetType(); var rpsAttributes = contentType .GetCustomAttributes(typeof(RedirectPropertySourceAttribute), false) .Cast <RedirectPropertySourceAttribute>() .Where(rpsa => !rpsa.ReadOnly) .ToList(); List <string> paths = rpsAttributes .Select(a => PathFunctions.Redirect(path, a.SourceDescriptor)) .Distinct() .ToList(); List <PropertyStore> records = Repository.Instance.Get(contentType, paths).ToList(); // Update the fetched referenced records with updated referenced properties on the content object JObject jObjectContent = JObject.FromObject(data); List <object> ids = new List <object>(); List <PropertyStore> vals = new List <PropertyStore>(); if (rpsAttributes.Any()) { foreach (var rpsAttribute in rpsAttributes) { string refdPath = PathFunctions.Redirect(path, rpsAttribute.SourceDescriptor); if (refdPath == path) // redirected to itself { continue; } PropertyStore refdRecord = records.FirstOrDefault(ps => (string)ps["Path"] == refdPath); if (refdRecord == null) { refdRecord = GetNewRecord(contentType, refdPath); } foreach (string propertyPath in rpsAttribute.PropertyPaths) { JObject refdObject = JObject.Parse((string)refdRecord["Content"]); var toFromPaths = GetPaths(propertyPath); refdObject.CopyPropertyFrom(toFromPaths[1], jObjectContent, toFromPaths[0]); refdRecord["Content"] = refdObject.ToString(); } if (!ids.Contains(refdPath)) { ids.Add(refdPath); vals.Add(refdRecord); } } if (vals.Count > 0) { Repository.Instance.Set(contentType, vals, ids); } } return(jObjectContent); }
/// <summary> /// Sample code showing how to dump all properties on a file including looking up /// the names of the properties. /// </summary> /// <param name="filename">Name of the file on which to dump all properties.</param> public static void DumpAllProperties(string filename) { Console.WriteLine("All properties in '{0}'.", filename); var propList = new List <KeyValuePair <string, string> >(); using (var propSys = new PropertySystem()) { using (var propStore = PropertyStore.Open(filename)) { int count = propStore.Count; for (int i = 0; i < count; ++i) { // Get the key for the enumerated property PropertyKey propKey = propStore.GetAt(i); // Get the description from the property store (if available) var desc = propSys.GetPropertyDescription(propKey); // Get the value object value = null; try { value = propStore.GetValue(propKey); } catch (NotImplementedException err) { value = err.Message; } string valueStr = ValueToString(value); // Retrieve or generate a name string name; if (desc != null) { name = string.Format("{0} ({1}) ({2}, {3})", desc.CanonicalName, desc.DisplayName, (ShortPropTypeFlags)desc.TypeFlags, propStore.IsPropertyWriteable(propKey) ? "Writable" : "ReadOnly"); } else { name = string.Format("{0}, {1}", propKey.PropSetId, propKey.PropertyId); } // Add to the list propList.Add(new KeyValuePair <string, string>(name, valueStr)); } } } // Sort the list by key propList.Sort((a, b) => a.Key.CompareTo(b.Key)); // Dump the list foreach (var pair in propList) { Console.WriteLine("{0}: {1}", pair.Key, pair.Value); } } // DumpAllProperties
public IUser GetUser(string userName) { PropertyStore ps = this.Get(typeof(User), new Dictionary <string, object> { { "UserName = @userName", userName } }, new List <string>(), false).FirstOrDefault(); return(ps == null ? null : ps.Project <User>()); }
public IUser GetUserByEmail(string email) { PropertyStore ps = this.Get(typeof(User), new Dictionary <string, object> { { "Email = @email", email } }, new List <string>(), false).FirstOrDefault(); return(ps == null ? null : ps.Project <User>()); }
/// <summary> /// Gives content object stored in a content record /// </summary> /// <param name="isBaseContent">If content object is of type BaseContent - if so supplied OriginalRecord property</param> /// <param name="type">type of content object</param> /// <param name="ps">content record as property store</param> /// <returns>content object</returns> private object GetContent(bool isBaseContent, Type type, PropertyStore ps) { object content = ps.Project <ContentItem>().GetContent(type); //if (isBaseContent) // (content as BaseContent).OriginalRecord = ps; return(content); }
public void Delete(RouteValueDictionary values, object data) { var ci = GetContentItem(values, data); ci.SetContent(data); PropertyStore ps = new PropertyStore(); ps.Inject(ci); Repository.Instance.Delete(data.GetType(), ps, ci.Path); }
public void GetEnumerator_will_dedupe_values() { var composite = PropertyStore.Compose( Properties.FromValue(new { a = "1", b = "2" }), Properties.FromValue(new { a = "1000", d = "2" }) ); Assert.Equal(new [] { "a", "b", "d" }, composite.Select(t => t.Key)); }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (_propertyStore != null) { _propertyStore.Dispose(); _propertyStore = null; } }
public NeoStoreIndexStoreView(LockService locks, NeoStores neoStores) { this.Locks = locks; this._neoStores = neoStores; this.PropertyStore = neoStores.PropertyStore; this.NodeStore = neoStores.NodeStore; this.RelationshipStore = neoStores.RelationshipStore; this._counts = neoStores.Counts; }
public void GetPropertyType_checks_each() { var composite = PropertyStore.Compose( Properties.FromValue(new { a = 1, b = 2.0 }), Properties.FromValue(new { c = "1", d = 2.0m }) ); Assert.Equal(typeof(string), composite.GetPropertyType("c")); }
public IndexBatchTransactionApplier(IndexingService indexingService, WorkSync <System.Func <LabelScanWriter>, LabelUpdateWork> labelScanStoreSync, WorkSync <IndexingUpdateService, IndexUpdatesWork> indexUpdatesSync, NodeStore nodeStore, RelationshipStore relationshipStore, PropertyStore propertyStore, IndexActivator indexActivator) { this._indexingService = indexingService; this._labelScanStoreSync = labelScanStoreSync; this._indexUpdatesSync = indexUpdatesSync; this._propertyStore = propertyStore; this._transactionApplier = new SingleTransactionApplier(this, nodeStore, relationshipStore); this._indexActivator = indexActivator; }
/// <summary> /// Apply the current values to the underlying objects associated with the /// property page as previously passed to IPropertyPage::SetObjects. /// </summary> public void Apply() { // Save the changed value to PropertyStore. if (_propertyToBePersisted.HasValue) { PropertyStore.Persist(_propertyToBePersisted.Value.Key, _propertyToBePersisted.Value.Value); _propertyToBePersisted = null; } }
protected virtual object GetSummary(Type type, PropertyStore ps) { var contentItem = ps.Project <ContentItem>(); var summary = contentItem.GetSummary(type) as Summary; summary.Url = ContentMap.Instance.GetUrls(contentItem).FirstOrDefault(); summary.Type = ContentTypeHierarchy.AllContentTypes.FirstOrDefault(t => t.FullName == contentItem.DataType); summary.Id = contentItem.Identity.ToString(); return(summary); }
public PropertyStore Load() { var cmdProps = new PropertyStore(); if (_commandLineArgs != null && _commandLineArgs.Length > 0) { var argsCmd = CommandLineParser.ParseCommandLineArgs(_commandLineArgs); cmdProps.Merge(argsCmd.ToParameterMap()); } return cmdProps; }
public NodeImporter(BatchingNeoStores stores, IdMapper idMapper, Monitor monitor) : base(stores, monitor) { this._labelTokenRepository = stores.LabelRepository; this._idMapper = idMapper; this._nodeStore = stores.NodeStore; this._nodeRecord = _nodeStore.newRecord(); this._nodeIds = new BatchingIdGetter(_nodeStore); this._idPropertyStore = stores.TemporaryPropertyStore; this._idPropertyRecord = _idPropertyStore.newRecord(); _nodeRecord.InUse = true; }
public void Delete(Type type, PropertyStore val, object id) { var query = QueryBuilderFactory.Instance.Create(); query.SqlConditionals.Add(GetIdName(type) + " = @id"); query.SqlParameters.Add("@id", id); // Assumes int primary keys will be identities val.Where(kvp => kvp.Key != GetIdName(type) || !(kvp.Value is int)) .Do(kvp => query.SqlSets.Add(kvp.Key, kvp.Value)); query = ProcessQuerySet.Process(query); query.SqlTable = GetTableName(type); query.RunDelete(); }
public PropertyStore Load() { var properties = new PropertyStore(); try { var tmp = Parse(_rawPropertiesData); properties.Merge(tmp); } catch (FormatException e) { throw new PropertySourceException("Failed to parse properties data!", e); } return properties; }
public void Delete(Type type, PropertyStore val, object id) { var query = GetQuery(type, val, id, ProcessQueryDelete); query.RunDelete(); }
/// <summary> /// Efficiently gets from database and collates all data referenced by property source redirects /// </summary> /// <param name="primaryPath">path of main item</param> /// <param name="primaryRecord">data record of main item, if already available, or else null</param> /// <param name="contentType">type of main content object</param> /// <returns>content object</returns> protected virtual object GetWithRelated(string primaryPath, PropertyStore primaryRecord, Type contentType) { // Establish the records to fetch and fetch them var rpsAttributes = contentType .GetCustomAttributes(typeof(RedirectPropertySourceAttribute), false) .Cast<RedirectPropertySourceAttribute>() .ToList(); List<string> paths = new List<string>(); if (primaryRecord == null) paths.Add(primaryPath); paths.AddRange(rpsAttributes .Select(a => PathFunctions.Redirect(primaryPath, a.SourceDescriptor)) .Distinct()); List<PropertyStore> records = Repository.Instance.Get(contentType, paths).ToList(); // Update the primary record with redirected properties from referenced records if (primaryRecord == null) primaryRecord = records.FirstOrDefault(ps => ((string)ps["Path"]) == primaryPath); if (primaryRecord == null) return null; JObject jContent = null; if (rpsAttributes.Any()) { jContent = JObject.Parse((string)primaryRecord["Content"]); foreach (var rpsAttribute in rpsAttributes) { string refdPath = PathFunctions.Redirect(primaryPath, rpsAttribute.SourceDescriptor); if (refdPath == primaryPath) // redirected to itself continue; PropertyStore refdRecord = records.FirstOrDefault(ps => (string)ps["Path"] == refdPath); if (refdRecord != null) foreach (string propertyPath in rpsAttribute.PropertyPaths) { var toFromPaths = GetPaths(propertyPath); JObject refdObject = JObject.Parse((string)refdRecord["Content"]); jContent.CopyPropertyFrom(toFromPaths[0], refdObject, toFromPaths[1]); } } } bool isBaseContent = typeof(BaseContent).IsAssignableFrom(contentType); if (jContent == null) return GetContent(isBaseContent, contentType, primaryRecord); object content = jContent.ToObject(contentType); //if (isBaseContent) // (content as BaseContent).OriginalRecord = primaryRecord; return content; }
public virtual void SetUp() { Values = new PropertySet(); Store = new PropertyStore(Values, new JsonMapping()); }
private void InterpretProperties(PropertyStore properties) { var allProperties = properties.ToKeyValuePairs(); foreach (var key in allProperties.Keys) { if (key.Contains(".$hidden")) { var hiddenValue = properties.Get(key); properties.Set(key.Replace(".$hidden", ""), Unhide(hiddenValue)); } } }
public virtual void TearDown() { Values = null; Store = null; }
/// <summary> /// Disposes the <see cref="MMDevice"/> and its default property store (see <see cref="PropertyStore"/> property). /// </summary> /// <param name="disposing">True to release both managed and unmanaged resources; false to release only unmanaged resources.</param> protected override void Dispose(bool disposing) { if (_disposed) return; if (_propertyStore != null) { _propertyStore.Dispose(); _propertyStore = null; } _disposed = true; base.Dispose(disposing); }
protected virtual object GetSummary(Type type, PropertyStore ps) { var contentItem = ps.Project<ContentItem>(); var summary = contentItem.GetSummary(type) as Summary; summary.Url = ContentMap.Instance.GetUrls(contentItem).FirstOrDefault(); summary.Type = ContentTypeHierarchy.AllContentTypes.FirstOrDefault(t => t.FullName == contentItem.DataType); summary.Id = contentItem.Identity.ToString(); return summary; }
public PropertyMapping(PropertyStore properties) { Properties = properties; }
/// <summary> /// Gives content object stored in a content record /// </summary> /// <param name="isBaseContent">If content object is of type BaseContent - if so supplied OriginalRecord property</param> /// <param name="type">type of content object</param> /// <param name="ps">content record as property store</param> /// <returns>content object</returns> private object GetContent(bool isBaseContent, Type type, PropertyStore ps) { object content = ps.Project<ContentItem>().GetContent(type); //if (isBaseContent) // (content as BaseContent).OriginalRecord = ps; return content; }
protected virtual IQueryBuilder GetQuery(Type type, PropertyStore val, object id, OrderedProcess<IQueryBuilder> processQuery) { if (id != null && !(id is string)) throw new ArgumentException("Invalid id type " + id.GetType().FullName); var query = QueryBuilderFactory.Instance.Create(); query.SqlConditionals.Add("DataType = @dataType"); query.SqlParameters.Add("@dataType", type.FullName); if (id != null) { query.SqlConditionals.Add("Path = @path"); query.SqlParameters.Add("@path", id); } else query.SqlConditionals.Add("Path IS NULL"); if ((Guid)val["Id"] == Guid.Empty) { // Initialise new ContentItem val["Path"] = id; val["DataType"] = type.FullName; val["Id"] = Guid.NewGuid(); if ((Guid)val["Identity"] == Guid.Empty) val["Identity"] = Guid.NewGuid(); } val.Do(kvp => query.SqlSets.Add(kvp.Key, kvp.Value)); query.PreservedFields.Add("Id"); query.PreservedFields.Add("Identity"); query = processQuery.Process(query); query.SqlTable = "ContentItems"; return query; }
public void Set(Type type, PropertyStore val, object id) { var query = GetQuery(type, val, id, ProcessQuerySet); query.ShouldInsert = false; // int affected = query.RunUpdateInsert(); if (affected == 0) // insert ContentTypeHierarchy.EnsureContainsType(type); // this might be the first content item of this type in the db }
public ValueConfigurator(PropertyStore configuration) { _configuration = configuration; }