/// <summary> /// Creates a new network database instance /// </summary> /// <param name="path">The path to the database file</param> /// <param name="registrar">The descripto registrar</param> public NetworkDb(string path, DescriptorRegistrar registrar) { this._disposed = false; this._path = path; this._registrar = registrar; this._createConnection(); this._ensureSchema(); }
public void BeforeTest() { var tf = new TypeFinder(); Dr = DescriptorRegistrar.Create(tf); Dr.Reset(); InspectorContainer.Current.Register <UISleuth.Reactions.SurfaceManager, DefaultSurfaceManager>(); InspectorContainer.Current.Register <ITypeFinder, TypeFinder>(); InspectorContainer.Current.Register <IInspectorThread, FakeInspectorThread>(); InspectorContainer.Current.Register <ICodeLoader, FakeCodeLoader>(); InspectorContainer.Current.Register <IScreenShot, FakeScreenShot>(); }
public void BeforeTest() { var kernel = new StandardKernel(); kernel.Bind <IDesignThread>().To <FakeDesignThread>(); kernel.Bind <DesignSurfaceManager <VisualElement> >().To <XamarinDesignSurfaceManager>(); kernel.Bind <IXenCodeLoader>().To <FakeXenCodeLoader>(); kernel.Bind <ITypeFinder>().To <TypeFinder>(); Dr = DescriptorRegistrar.Create(new TypeFinder()); Dr.Reset(); Reaction.Reset(); Reaction.GetServices = obj => { kernel.Inject(obj); }; }
/// <summary> /// Executes the command /// </summary> /// <param name="registrar">The registrar of descriptor types</param> /// <param name="query">The descriptor query</param> /// <returns>The descriptors that match the query</returns> public List <ObjectInfo> Execute(DescriptorRegistrar registrar, DescriptorQuery query) { List <ObjectInfo> ret = new List <ObjectInfo>(); lock (this) { _deviceInstance.Value = query.DeviceInstance; _objectType.Value = query.ObjectType; using (var reader = _command.ExecuteReader()) { int deviceInstanceOrdinal = reader.GetOrdinal("device_instance"); int objectTypeOrdinal = reader.GetOrdinal("object_type"); int instanceOrdinal = reader.GetOrdinal("instance"); int vendorIdOrdinal = reader.GetOrdinal("vendor_id"); int nameOrdinal = reader.GetOrdinal("name"); int propsOrdinal = reader.GetOrdinal("props"); while (reader.Read()) { uint deviceInstance = (uint)reader.GetInt32(deviceInstanceOrdinal); ushort objectType = (ushort)reader.GetInt32(objectTypeOrdinal); uint instance = (uint)reader.GetInt32(instanceOrdinal); ushort vendorId = (ushort)reader.GetInt32(vendorIdOrdinal); string name = reader.IsDBNull(nameOrdinal) ? null : reader.GetString(nameOrdinal); if (query.NameRegex == null || (name != null && Regex.IsMatch(name, query.NameRegex, RegexOptions.IgnoreCase))) { var info = registrar.CreateDescriptor( vendorId, deviceInstance, new ObjectId(objectType, instance)); info.Name = name; if (!reader.IsDBNull(propsOrdinal)) { var props = reader.GetString(propsOrdinal); info.LoadProperties(props); } ret.Add(info); } } } } return(ret); }
public void Initialize(ITypeFinder typeFinder, IDesignThread thread, IXenCodeLoader loader, DesignSurfaceManager <TVisualElement> surface) { if (RootView == null) { throw new InvalidOperationException($"The class was registered with the wrong {nameof(Register)} overload. No {RootView} was assigned."); } _dr = DescriptorRegistrar.Create(typeFinder); XamlWriter = new XenXamlWriter(); TypeFinder = typeFinder; Surface = surface; DesignThread = thread; DesignThread.Context = RootView; Loader = loader; Root = Surface.SetDesignSurface(RootView); }
/// <summary> /// Executes the command /// </summary> /// <param name="registrar">The registrar of descriptor types</param> /// <param name="deviceInstance">The device instance of the object to get</param> /// <param name="objectIdentifier">The object identifier of the object to get</param> /// <returns>The descriptors that match the query</returns> public ObjectInfo Execute(DescriptorRegistrar registrar, uint deviceInstance, ObjectId objectIdentifier) { ObjectInfo info = null; lock (this) { _deviceInstance.Value = deviceInstance; _objectType.Value = objectIdentifier.Type; _instance.Value = objectIdentifier.Instance; using (var reader = _command.ExecuteReader()) { int vendorIdOrdinal = reader.GetOrdinal("vendor_id"); int nameOrdinal = reader.GetOrdinal("name"); int propsOrdinal = reader.GetOrdinal("props"); if (reader.Read()) { ushort vendorId = (ushort)reader.GetInt32(vendorIdOrdinal); string name = reader.IsDBNull(nameOrdinal) ? null : reader.GetString(nameOrdinal); info = registrar.CreateDescriptor( vendorId, deviceInstance, objectIdentifier); info.Name = name; if (!reader.IsDBNull(propsOrdinal)) { var props = reader.GetString(propsOrdinal); info.LoadProperties(props); } } } } return(info); }
public void BeforeTest() { Dr = DescriptorRegistrar.Create(new TypeFinder()); Dr.Reset(); }
/// <summary> /// Constructs a new network database options instance /// </summary> public NetworkDatabaseOptions() { this.ProcessId = DefaultProcessIds.NetworkDatabase; this.DatabasePath = "network.db"; this.DescriptorRegistrar = new DescriptorRegistrar(); }