public void AttachToModel(Reference @ref) { reference = @ref; Detached = false; reference.PropertyChanged += reference_PropertyChanged; SetupForm(); }
public async Task<bool> WaitAsync(Reference<int> callerState) { if (_disposed) return false; var localState = _state; if (callerState.Value != localState) { callerState.Value = localState; return false; } TaskCompletionSource<object> taskCompletionSource; lock (_locker) { if (callerState.Value != _state) { callerState.Value = _state; return false; } taskCompletionSource = new TaskCompletionSource<object>(); _pending.AddLast(taskCompletionSource); callerState.Value = _state; } await taskCompletionSource.Task.ConfigureAwait(false); return true; }
public StorageActionsAccessor(TableStorage storage, Reference<WriteBatch> writeBatch, Reference<SnapshotReader> snapshot, IdGenerator generator, IBufferPool bufferPool, OrderedPartCollection<AbstractFileCodec> fileCodecs) : base(snapshot, generator, bufferPool) { this.storage = storage; this.writeBatch = writeBatch; this.fileCodecs = fileCodecs; }
private AssemblyInfo(string path, string name, Version version, Reference[] references) { Path = path; Name = name; Version = version; References = references; }
public void SkipTasksForDisabledIndexes1(string requestedStorage) { using (var storage = NewTransactionalStorage(requestedStorage)) { storage.Batch(accessor => accessor.Tasks.AddTask(new RemoveFromIndexTask(101), DateTime.Now)); storage.Batch(accessor => { var foundWork = new Reference<bool>(); var idsToSkip = new List<int>() { 101 }; var task = accessor.Tasks.GetMergedTask<RemoveFromIndexTask>( x => MaxTaskIdStatus.Updated, x => { }, foundWork, idsToSkip); Assert.Null(task); }); storage.Batch(accessor => { Assert.True(accessor.Tasks.HasTasks); Assert.Equal(1, accessor.Tasks.ApproximateTaskCount); }); } }
public override void OnCreate(object view) { foreach (var member in GetAttributeMembers(view.GetType())) { var key = member.Attribute.Key ?? member.MemberType.FullName; Reference reference; if (!store.TryGetValue(key, out reference)) { reference = new Reference { Context = Activator.CreateInstance(member.Attribute.Context ?? member.MemberType) }; var support = reference.Context as IViewContextSupport; if (support != null) { support.Initilize(); } store[key] = reference; } reference.Counter++; member.SetValue(view, reference.Context); } }
/// <summary> /// Default constructor /// </summary> /// <param name="doc"></param> /// <param name="spaceReference"></param> public RoomSpace(Document doc, Reference spaceReference) { m_doc = doc; LightFixtures = new List<LightFixture>(); Space refSpace = m_doc.GetElement(spaceReference) as Space; // Set properties of newly create RoomSpace object from Space AverageEstimatedIllumination = refSpace.AverageEstimatedIllumination; Area = refSpace.Area; CeilingReflectance = refSpace.CeilingReflectance; FloorReflectance = refSpace.FloorReflectance; WallReflectance = refSpace.WallReflectance; CalcWorkPlane = refSpace.LightingCalculationWorkplane; ParentSpaceObject = refSpace; // Populate light fixtures list for RoomSpace FilteredElementCollector fec = new FilteredElementCollector(m_doc) .OfCategory(BuiltInCategory.OST_LightingFixtures) .OfClass(typeof(FamilyInstance)); foreach (FamilyInstance fi in fec) { if (fi.Space.Id == refSpace.Id) { ElementId eID = fi.GetTypeId(); Element e = m_doc.GetElement(eID); //TaskDialog.Show("C","LF: SPACEID " + fi.Space.Id.ToString() + "\nSPACE ID: " + refSpace.Id.ToString()); LightFixtures.Add(new LightFixture(e,fi)); } } }
private bool CheckDirectDataAccess(Namespace ns, List<Wire> wires, string dataModule, Reference reference, Service serv) { Component comp = serv.Component; bool hasDirectDataAccess = false; List<Binding> bindings = new List<Binding>(); if (serv.Binding != null) bindings.Add(serv.Binding); if (reference.Binding != null) bindings.Add(reference.Binding); BindingTypeHolder binding = bindingGenerator.CheckForBindings(bindings); if (!binding.hasAnyBinding()) { // direct access if (comp.Name == dataModule || dataModule == ANY && serv.Interface is Database) { hasDirectDataAccess = true; } else { // need to check hasDirectDataAccess = HasDirectDataAccess(ns, wires, comp, dataModule); } } return hasDirectDataAccess; }
public void CanContructEscapedReferences() { var value = "identifier#property"; var reference = new Reference(value); Assert.AreEqual(reference.Identifier, "identifier"); Assert.AreEqual(reference.PropertyNames, new List<string> { "property" }); Assert.AreEqual(value, reference.Value); value = ("identifier#property.subProperty"); reference = new Reference(value); Assert.AreEqual(reference.Identifier, "identifier"); Assert.AreEqual(reference.PropertyNames, new List<string> { "property", "subProperty" }); Assert.AreEqual(value, reference.Value); value = @"\#identif\\\\\#ier\.\\#propertyName.\.abc\\.def"; reference = new Reference(value); Assert.AreEqual(reference.Identifier, @"#identif\\#ier.\"); Assert.AreEqual(reference.PropertyNames, new List<string> { "propertyName", @".abc\", "def" }); Assert.AreEqual(value, reference.Value); value = @"#propertyName.\.abc\\.def"; reference = new Reference(value); Assert.IsEmpty(reference.Identifier); Assert.AreEqual(reference.PropertyNames, new List<string> { "propertyName", @".abc\", "def" }); Assert.AreEqual(value, reference.Value); }
public static Autodesk.DesignScript.Geometry.Curve ToProtoType(this Autodesk.Revit.DB.Curve revitCurve, bool performHostUnitConversion = true, Reference referenceOverride = null) { if (revitCurve == null) { throw new ArgumentNullException("revitCurve"); } dynamic dyCrv = revitCurve; Autodesk.DesignScript.Geometry.Curve converted = RevitToProtoCurve.Convert(dyCrv); if (converted == null) { throw new Exception("An unexpected failure occurred when attempting to convert the curve"); } converted = performHostUnitConversion ? converted.InDynamoUnits() : converted; // If possible, add a geometry reference for downstream Element creation var revitRef = referenceOverride ?? revitCurve.Reference; if (revitRef != null) { converted.Tags.AddTag(ElementCurveReference.DefaultTag, revitRef); } return converted; }
/// <summary> /// Create a new dimension element using the given /// references and dimension line end points. /// This method opens and commits its own transaction, /// assuming that no transaction is open yet and manual /// transaction mode is being used. /// Note that this has only been tested so far using /// references to surfaces on planar walls in a plan /// view. /// </summary> public static void CreateDimensionElement( View view, XYZ p1, Reference r1, XYZ p2, Reference r2) { Document doc = view.Document; ReferenceArray ra = new ReferenceArray(); ra.Append( r1 ); ra.Append( r2 ); Line line = Line.CreateBound( p1, p2 ); using( Transaction t = new Transaction( doc ) ) { t.Start( "Create New Dimension" ); Dimension dim = doc.Create.NewDimension( view, line, ra ); t.Commit(); } }
protected override bool IsIndexStale(IndexStats indexesStat, IStorageActionsAccessor actions, bool isIdle, Reference<bool> onlyFoundIdleWork) { var isStale = actions.Staleness.IsMapStale(indexesStat.Id); var indexingPriority = indexesStat.Priority; if (isStale == false) return false; if (indexingPriority == IndexingPriority.None) return true; if ((indexingPriority & IndexingPriority.Normal) == IndexingPriority.Normal) { onlyFoundIdleWork.Value = false; return true; } if ((indexingPriority & (IndexingPriority.Disabled | IndexingPriority.Error)) != IndexingPriority.None) return false; if (isIdle == false) return false; // everything else is only valid on idle runs if ((indexingPriority & IndexingPriority.Idle) == IndexingPriority.Idle) return true; if ((indexingPriority & IndexingPriority.Abandoned) == IndexingPriority.Abandoned) { var timeSinceLastIndexing = (SystemTime.UtcNow - indexesStat.LastIndexingTime); return (timeSinceLastIndexing > context.Configuration.TimeToWaitBeforeRunningAbandonedIndexes); } throw new InvalidOperationException("Unknown indexing priority for index " + indexesStat.Id + ": " + indexesStat.Priority); }
public CommandManager(string clientId, Reference<Player> playerReference, IWorld word, INotificationService notificationService) { _clientId = clientId; _playerReference = playerReference; _world = word; _notificationService = notificationService; }
protected override void ImplementInvokeMethodOnTarget(AbstractTypeEmitter @class, ParameterInfo[] parameters, MethodEmitter invokeMethodOnTarget, MethodInfo callbackMethod, Reference targetField) { invokeMethodOnTarget.CodeBuilder.AddStatement( new ExpressionStatement( new MethodInvocationExpression(SelfReference.Self, InvocationMethods.EnsureValidTarget))); base.ImplementInvokeMethodOnTarget(@class, parameters, invokeMethodOnTarget, callbackMethod, targetField); }
/// <summary> /// Initializes a new instance of the Argument class. /// </summary> /// <param name="name">The optional name of the argument.</param> /// <param name="modifiers">Modifers applied to this argument.</param> /// <param name="argumentExpression">The expression that forms the body of the argument.</param> /// <param name="location">The location of the argument in the code.</param> /// <param name="parent">The parent code part.</param> /// <param name="tokens">The tokens that form the argument.</param> /// <param name="generated">Indicates whether the argument is located within a block of generated code.</param> internal Argument( CsToken name, ParameterModifiers modifiers, Expression argumentExpression, CodeLocation location, Reference<ICodePart> parent, CsTokenList tokens, bool generated) { Param.Ignore(name); Param.Ignore(modifiers); Param.AssertNotNull(argumentExpression, "argumentExpression"); Param.AssertNotNull(location, "location"); Param.AssertNotNull(parent, "parent"); Param.Ignore(tokens); Param.Ignore(generated); this.name = name; this.modifiers = modifiers; this.argumentExpression = argumentExpression; this.location = location; this.parent = parent; this.tokens = tokens; this.generated = generated; }
public QueueStorageActions(TableStorage tableStorage, IUuidGenerator generator, Reference<SnapshotReader> snapshot, Reference<WriteBatch> writeBatch, IBufferPool bufferPool) : base(snapshot, bufferPool) { this.tableStorage = tableStorage; this.writeBatch = writeBatch; this.generator = generator; }
public static ReferenceType DetermineReferenceType(Reference reference) { if (reference.Cardinality1 == Cardinality.Zero && reference.Cardinality2 == Cardinality.Zero) return ReferenceType.OneToOne; if (reference.Cardinality1 == Cardinality.One && reference.Cardinality2 == Cardinality.One) return ReferenceType.OneToOne; if (reference.Cardinality1 == Cardinality.One && reference.Cardinality2 == Cardinality.Zero) return ReferenceType.OneToOne; if (reference.Cardinality1 == Cardinality.Zero && reference.Cardinality2 == Cardinality.One) return ReferenceType.OneToOne; if (reference.Cardinality1 == Cardinality.One && reference.Cardinality2 == Cardinality.Many) return ReferenceType.ManyToOne; if (reference.Cardinality1 == Cardinality.Many && reference.Cardinality2 == Cardinality.One) return ReferenceType.ManyToOne; if (reference.Cardinality1 == Cardinality.Many && reference.Cardinality2 == Cardinality.Zero) return ReferenceType.ManyToOne; if (reference.Cardinality1 == Cardinality.Zero && reference.Cardinality2 == Cardinality.Many) return ReferenceType.ManyToOne; if (reference.Cardinality1 == Cardinality.Many && reference.Cardinality2 == Cardinality.Many) return ReferenceType.ManyToMany; return ReferenceType.Unsupported; }
public GeneralStorageActions(TableStorage storage, Reference<WriteBatch> writeBatch, Reference<SnapshotReader> snapshot, IBufferPool bufferPool) : base(snapshot, bufferPool) { this.storage = storage; this.writeBatch = writeBatch; this.snapshot = snapshot; }
public DirectedReference(Entity fromEntity, Reference reference) { this.fromEntity = fromEntity; this.reference = reference; fromIsEnd1 = reference.Entity1 == fromEntity; }
public override Evaluant.NLinq.Expressions.Expression Visit(Evaluant.NLinq.Expressions.MemberExpression expression) { if (expression.Previous == null) return base.Visit(expression); NLinq.Expressions.Expression previous = Visit(expression.Previous); Evaluant.NLinq.Expressions.Identifier propertyName = expression.Statement as Evaluant.NLinq.Expressions.Identifier; if (propertyName != null) { if (currentEntity.References.ContainsKey(propertyName.Text)) { currentReference = currentEntity.References[propertyName.Text]; currentEntity = engine.Factory.Model.Entities[currentReference.ChildType]; } else { currentReference = null; } } else { currentEntity = null; currentReference = null; } return updater.Update(expression, previous, Visit(expression.Statement)); }
public static IEnumerable<Surface> ToProtoType(this Autodesk.Revit.DB.Face revitFace, bool performHostUnitConversion = true, Reference referenceOverride = null) { if (revitFace == null) throw new ArgumentNullException("revitFace"); var revitEdgeLoops = EdgeLoopPartition.GetAllEdgeLoopsFromRevitFace(revitFace); var partitionedRevitEdgeLoops = EdgeLoopPartition.ByEdgeLoopsAndFace(revitFace, revitEdgeLoops); var listSurface = new List<Surface>(); foreach (var edgeloopPartition in partitionedRevitEdgeLoops) { // convert the trimming curves var edgeLoops = EdgeLoopsAsPolyCurves(revitFace, edgeloopPartition); // convert the underrlying surface var dyFace = (dynamic)revitFace; Surface untrimmedSrf = SurfaceExtractor.ExtractSurface(dyFace, edgeLoops); if (untrimmedSrf == null) throw new Exception("Failed to extract surface"); // trim the surface Surface converted = untrimmedSrf.TrimWithEdgeLoops(edgeLoops); // perform unit conversion if necessary converted = performHostUnitConversion ? converted.InDynamoUnits() : converted; // if possible, apply revit reference var revitRef = referenceOverride ?? revitFace.Reference; if (revitRef != null) converted = ElementFaceReference.AddTag(converted, revitRef); listSurface.Add(converted); } return listSurface; }
internal static async Task<Stream> DownloadAsyncImpl(IHoldProfilingInformation self, HttpJsonRequestFactory requestFactory, FilesConvention conventions, NameValueCollection operationsHeaders, string path, string filename, Reference<RavenJObject> metadataRef, long? @from, long? to, string baseUrl, OperationCredentials credentials) { var request = requestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(self, baseUrl + path + Uri.EscapeDataString(filename), "GET", credentials, conventions)).AddOperationHeaders(operationsHeaders); if (@from != null) { if (to != null) request.AddRange(@from.Value, to.Value); else request.AddRange(@from.Value); } try { var response = await request.ExecuteRawResponseAsync().ConfigureAwait(false); if (response.StatusCode == HttpStatusCode.NotFound) throw new FileNotFoundException("The file requested does not exists on the file system.", baseUrl + path + filename); await response.AssertNotFailingResponse().ConfigureAwait(false); if (metadataRef != null) metadataRef.Value = response.HeadersToObject(); return new DisposableStream(await response.GetResponseStreamWithHttpDecompression().ConfigureAwait(false), request.Dispose); } catch (Exception e) { throw e.SimplifyException(); } }
internal Invite(DiscordClient client, string code, string xkcdPass, string serverId, string inviterId, string channelId) : base(client, code) { XkcdCode = xkcdPass; _server = new Reference<Server>(serverId, x => { var server = _client.Servers[x]; if (server == null) { server = _generatedServer = new Server(client, x); server.Cache(); } return server; }); _inviter = new Reference<User>(serverId, x => { var inviter = _client.Users[x, _server.Id]; if (inviter == null) { inviter = _generatedInviter = new User(client, x, _server.Id); inviter.Cache(); } return inviter; }); _channel = new Reference<Channel>(serverId, x => { var channel = _client.Channels[x]; if (channel == null) { channel = _generatedChannel = new Channel(client, x, _server.Id, null); channel.Cache(); } return channel; }); }
private void OnDispatch(EventHandler<DispatcherEventArgs<Reference>> dispatched, Reference reference) { var handler = dispatched; if (handler != null) { handler.Invoke(this, new DispatcherEventArgs<Reference>(reference)); } }
public MappedResultsStorageActions(TableStorage tableStorage, IUuidGenerator generator, OrderedPartCollection<AbstractDocumentCodec> documentCodecs, Reference<SnapshotReader> snapshot, Reference<WriteBatch> writeBatch, IBufferPool bufferPool) : base(snapshot, bufferPool) { this.tableStorage = tableStorage; this.generator = generator; this.documentCodecs = documentCodecs; this.writeBatch = writeBatch; }
internal void Apply(MemTable memTable, Reference<ulong> seq) { foreach (var operation in _operations) { var itemType = operation.Op == Operations.Delete ? ItemType.Deletion : ItemType.Value; memTable.Add(seq.Value++, itemType, operation.Key, operation.Handle); } }
public IndexingStorageActions(TableStorage tableStorage, IUuidGenerator generator, Reference<SnapshotReader> snapshot, Reference<WriteBatch> writeBatch, IStorageActionsAccessor storageActionsAccessor, IBufferPool bufferPool) : base(snapshot, bufferPool) { this.tableStorage = tableStorage; this.generator = generator; this.writeBatch = writeBatch; this.currentStorageActionsAccessor = storageActionsAccessor; }
public void AddFileRefence(string name, string version) { Reference newRef = new Reference(); newRef.projectName = lastProjectName; newRef.Name = name; newRef.version = version; References.Add(newRef); }
public Reference NewReference() { lock (lck) { reference = reference.Increase; return reference; } }
protected override void AddEncoderToPipeline(bool hasInputReader) { base.AddEncoderToPipeline(hasInputReader, EncoderUnit.LogStream.StandardOut); // setup output parsing var einfo = new Reference<WebTranscodingInfo>(() => Context.TranscodingInfo, x => { Context.TranscodingInfo = x; }); VLCWrapperParsingUnit logunit = new VLCWrapperParsingUnit(einfo, Context.MediaInfo, Context.StartPosition); Context.Pipeline.AddLogUnit(logunit, 6); }