/// <summary> /// Spawn a prefab that will be tracked & saved for a specific scene. /// </summary> /// <param name="source">Methodology to know where prefab came from </param> /// <param name="filePath">This is used to retrieve the prefab again from the designated source. </param> /// <param name="scene">Saved prefabs are bound to a specific scene. Easiest way to reference is by passing through (gameObject.scene). /// By default is uses the active scene. </param> /// <returns> Instance of saved prefab. </returns> public static GameObject SpawnSavedPrefab(InstanceSource source, string filePath, Scene scene = default(Scene)) { if (!HasActiveSaveLogAction("Spawning Object")) { return(null); } // If no scene has been specified, it will use the current active scene. if (scene == default(Scene)) { scene = SceneManager.GetActiveScene(); } if (duplicatedSceneHandles.Contains(scene.GetHashCode())) { Debug.Log(string.Format("Following scene has a duplicate name: {0}. " + "Ensure to call SaveMaster.SpawnInstanceManager(scene, id) with a custom ID after spawning the scene.", scene.name)); scene = SceneManager.GetActiveScene(); } SaveInstanceManager saveIM; if (!saveInstanceManagers.TryGetValue(scene.GetHashCode(), out saveIM)) { saveIM = SpawnInstanceManager(scene); } return(saveIM.SpawnObject(source, filePath).gameObject); }
private void OnPropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == nameof(SelectedInstance)) { ProfileList = null; if (SelectedInstance != null) { new Thread(new ThreadStart( () => { Wizard.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => Wizard.ChangeTaskCount(+1))); try { // Get and load profile list. var profile_list = SelectedInstance.GetProfileList(InstanceSource.GetAuthenticatingInstance(SelectedInstance), Window.Abort.Token); // Send the loaded profile list back to the UI thread. Wizard.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => ProfileList = profile_list)); } catch (OperationCanceledException) { } catch (Exception ex) { Wizard.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => Wizard.Error = ex)); } finally { Wizard.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => Wizard.ChangeTaskCount(-1))); } })).Start(); } } }
/// <summary> /// Removes entire instance source from history /// </summary> private void ForgetInstanceSource() { // Deselect instance to prevent flickering of the profile list. SelectedInstance = null; SelectedProfile = null; InstanceSource.Forget(); if (InstanceSource is DistributedInstanceSource instance_source_distributed) { // Distributed authenticating instance source var authenticating_instance = instance_source_distributed.AuthenticatingInstance; if (authenticating_instance != null) { instance_source_distributed.AuthenticatingInstance = null; // Test if it is safe to remove authorization token and certificate. for (var source_index = (int)InstanceSourceType._start; source_index < (int)InstanceSourceType._end; source_index++) { if (source_index != (int)InstanceSourceType && Wizard.InstanceSources[source_index]?.AuthenticatingInstance != null && Wizard.InstanceSources[source_index].AuthenticatingInstance.Equals(authenticating_instance)) { return; } } authenticating_instance.Forget(); } } }
private void OnPropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == nameof(SelectedInstance)) { ProfileList = null; if (SelectedInstance != null) { new Thread(new ThreadStart( () => { Wizard.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => Wizard.ChangeTaskCount(+1))); try { // Get and load profile list. var profile_list = SelectedInstance.GetProfileList(InstanceSource.GetAuthenticatingInstance(SelectedInstance), Window.Abort.Token); // Send the loaded profile list back to the UI thread. // We're not navigating to another page and OnActivate() will not be called to auto-reset error message. Therefore, reset it manually. Wizard.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)( () => { Wizard.Error = null; ProfileList = profile_list; })); } catch (OperationCanceledException) { } catch (Exception ex) { Wizard.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => Wizard.Error = ex)); } finally { Wizard.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => Wizard.ChangeTaskCount(-1))); } })).Start(); } } }
public bool TryGetSource(ITypeSymbol target, out InstanceSource instanceSource) { if (_delegateParameters is not null && _delegateParameters.TryGetValue(target, out var delegateParameter)) { instanceSource = delegateParameter; return(true); } if (_instanceSource.TryGetValue(target, out instanceSource)) { return(true); } if (target is INamedTypeSymbol { DelegateInvokeMethod : { ReturnType : { } returnType, Parameters : var parameters } } delegateType) { if (returnType.OriginalDefinition.Equals(_task1Type, SymbolEqualityComparer.Default) || returnType.OriginalDefinition.Equals(_valueTask1Type, SymbolEqualityComparer.Default)) { instanceSource = new DelegateSource(delegateType, ((INamedTypeSymbol)returnType).TypeArguments[0], parameters, isAsync : true); } else { instanceSource = new DelegateSource(delegateType, returnType, parameters, isAsync: false); } return(true); } return(false); }
public static bool RequiresAsync(InstanceSource source, InstanceSourcesScope containerScope) { var visitor = new RequiresAsyncVisitor(containerScope); visitor.VisitCore(source, new State { InstanceSourcesScope = containerScope }); return(visitor._requiresAsync); }
public bool TryGetSource(ITypeSymbol target, out InstanceSource instanceSource, out bool isAmbiguous, out IEnumerable <FactoryMethod> sourcesNotMatchingConstraints) { if (!TryGetUnderlyingSource(target, out instanceSource, out isAmbiguous, out sourcesNotMatchingConstraints)) { return(false); } instanceSource = Decorate(instanceSource); return(true); }
/// <summary> /// Removes given instance from history /// </summary> /// <param name="instance">Instance</param> private void ForgetInstance(Instance instance) { InstanceSource.ForgetInstance(instance); // Test if it is safe to remove authorization token and certificate. for (var source_index = (int)InstanceSourceType._start; source_index < (int)InstanceSourceType._end; source_index++) { if (Wizard.InstanceSources[source_index]?.AuthenticatingInstance != null && Wizard.InstanceSources[source_index].AuthenticatingInstance.Equals(instance)) { return; } } instance.Forget(); }
public InstanceSourcesScope Enter(InstanceSource instanceSource) { switch (instanceSource) { case DelegateSource { parameters: var parameters } : var delegateParameters = _delegateParameters is null ? new Dictionary <ITypeSymbol, DelegateParameter>() : new Dictionary <ITypeSymbol, DelegateParameter>(_delegateParameters); foreach (var param in parameters) { delegateParameters[param.Type] = new DelegateParameter(param, "param" + Depth + "_" + param.Ordinal); } return(new InstanceSourcesScope(_containerScope, delegateParameters, Depth + 1));
public void InstanceSourceInfoTest() { // .NET 3.5 allows Schannel to use SSL 3 and TLS 1.0 by default. Instead of hacking user computer's registry, extend it in runtime. // System.Net.SecurityProtocolType lacks appropriate constants prior to .NET 4.5. ServicePointManager.SecurityProtocol = (SecurityProtocolType)0x0C00; var pub_key = Convert.FromBase64String("E5On0JTtyUVZmcWd+I/FXRm32nSq8R2ioyW7dcu/U88="); Parallel.ForEach(new List <ResourceRef>() { new ResourceRef() { Uri = new Uri("https://static.eduvpn.nl/disco/institute_access.json"), PublicKey = pub_key, }, new ResourceRef() { Uri = new Uri("https://static.eduvpn.nl/disco/secure_internet.json"), PublicKey = pub_key, }, }, source => { // Load list of instances. var instance_source_json = Xml.Response.Get(source); var instance_source_ia = new InstanceSource(); instance_source_ia.LoadJSON(instance_source_json.Value); // Load all instances APIs. Parallel.ForEach(instance_source_ia.InstanceList, i => { var uri_builder = new UriBuilder(i.Base); uri_builder.Path += "info.json"; try { new Models.InstanceEndpoints().LoadJSON(Xml.Response.Get(uri_builder.Uri).Value); } catch (AggregateException ex) { if (ex.InnerException is WebException ex_web && (ex_web.Status == WebExceptionStatus.ConnectFailure || ex_web.Status == WebExceptionStatus.SecureChannelFailure)) { // Ignore connection failure WebException(s), as some instances are not publicly available or have other issues. } else { throw; } }
private bool TryGetUnderlyingSource(ITypeSymbol target, out InstanceSource instanceSource, out bool isAmbiguous, out IEnumerable <FactoryMethod> sourcesNotMatchingConstraints) { isAmbiguous = false; sourcesNotMatchingConstraints = Array.Empty <FactoryMethod>(); if (_delegateParameters is not null && _delegateParameters.TryGetValue(target, out var delegateParameter)) { instanceSource = delegateParameter; return(true); } if (_instanceSources.TryGetValue(target, out var instanceSources)) { instanceSource = instanceSources.Best !; isAmbiguous = instanceSource is null; return(!isAmbiguous); } if (_genericRegistrationsResolver.TryResolve(target, out var constructedFactoryMethod, out isAmbiguous, out sourcesNotMatchingConstraints)) { instanceSource = constructedFactoryMethod; return(true); }
public void InstanceSourceInfoTest() { // .NET 3.5 allows Schannel to use SSL 3 and TLS 1.0 by default. Instead of hacking user computer's registry, extend it in runtime. // System.Net.SecurityProtocolType lacks appropriate constants prior to .NET 4.5. ServicePointManager.SecurityProtocol = (SecurityProtocolType)0x0C00; var pub_key = Convert.FromBase64String("E5On0JTtyUVZmcWd+I/FXRm32nSq8R2ioyW7dcu/U88="); Parallel.ForEach(new List <KeyValuePair <Uri, byte[]> >() { new KeyValuePair <Uri, byte[]>(new Uri("https://static.eduvpn.nl/disco/institute_access.json"), pub_key), new KeyValuePair <Uri, byte[]>(new Uri("https://static.eduvpn.nl/disco/secure_internet.json"), pub_key), }, source => { // Load list of instances. var instance_source_json = Xml.Response.Get( uri: source.Key, pub_key: source.Value); var instance_source_ia = new InstanceSource(); instance_source_ia.LoadJSON(instance_source_json.Value); // Load all instances APIs. Parallel.ForEach(instance_source_ia.InstanceList, i => { var uri_builder = new UriBuilder(i.Base); uri_builder.Path += "info.json"; new Models.InstanceEndpoints().LoadJSON(Xml.Response.Get(uri_builder.Uri).Value); }); // Re-load list of instances. instance_source_json = Xml.Response.Get( uri: source.Key, pub_key: source.Value, previous: instance_source_json); }); }
public SavedInstance SpawnObject(InstanceSource source, string filePath, string saveIdentification = "") { GameObject getResource = null; // Implement more spawn methods here. // Such as usage for Asset Bundles & Adressables switch (source) { case InstanceSource.Resources: getResource = Resources.Load(filePath) as GameObject; break; default: break; } if (getResource == null) { Debug.LogWarning(string.Format("Invalid resource path: {0}", filePath)); return(null); } changesMade++; // We will temporarily set the resource to disabled. Because we don't want to enable any // of the components yet. bool resourceState = getResource.gameObject.activeSelf; getResource.gameObject.SetActive(false); GameObject instance = GameObject.Instantiate(getResource, getResource.transform.position, getResource.transform.rotation); SceneManager.MoveGameObjectToScene(instance.gameObject, this.gameObject.scene); // After instantiating we reset the resource back to it's original state. getResource.gameObject.SetActive(resourceState); Saveable saveable = instance.GetComponent <Saveable>(); if (saveable == null) { Debug.LogWarning("Save Instance Manager: No saveable added to spawned object." + " Scanning for ISaveables during runtime is more costly."); saveable = instance.AddComponent <Saveable>(); saveable.ScanAddSaveableComponents(); } SavedInstance savedInstance = instance.AddComponent <SavedInstance>(); savedInstance.Configure(saveable, this); // In case the object has no idenfication, which applies to all prefabs. // Then we give it a new identification, and we store it into our spawninfo array so we know to spawn it again. if (string.IsNullOrEmpty(saveIdentification)) { saveable.SaveIdentification = string.Format("{0}-{1}-{2}", SceneID, saveable.name, spawnCountHistory); spawnInfo.Add(savedInstance, new SpawnInfo() { filePath = filePath, saveIdentification = saveable.SaveIdentification, source = source }); spawnCountHistory++; loadedIDs.Add(saveable.SaveIdentification); } else { saveable.SaveIdentification = saveIdentification; loadedIDs.Add(saveable.SaveIdentification); } instance.gameObject.SetActive(true); return(savedInstance); }
public static GameObject SpawnSavedPrefab(InstanceSource source, string filePath) { return(HasActiveSave("Spawning Object") == false ? null : saveInstanceManager.SpawnObject(source, filePath)); }
public MainPipe AddSourceTask(MainPipe dataFlow, string Name, string SourceName, SourceType Sourcetype, ConnectionManager conMgrSource, out IDTSComponentMetaData100 sourceTask, bool SQLStatementASVariable = false, string ConnectionString = "") { CManagedComponentWrapper InstanceSource; switch (Sourcetype) { case SourceType.SELECTSQL: sourceTask = dataFlow.AddPipeLine(SSISMoniker.OLEDB_SOURCE, Name + " Source"); break; case SourceType.Table: sourceTask = dataFlow.AddPipeLine(SSISMoniker.OLEDB_SOURCE, Name + " Source"); break; case SourceType.FlatFile: sourceTask = dataFlow.AddPipeLine(SSISMoniker.FLAT_FILE_SOURCE, Name + " Source"); break; case SourceType.Excel: sourceTask = dataFlow.AddPipeLine(SSISMoniker.EXCEL_SOURCE, Name + " Source"); break; case SourceType.TableStorage: sourceTask = dataFlow.AddPipeLine(SSISMoniker.OLEDB_TABLESTORAGE_SOURCE, Name + " Source"); break; case SourceType.SPList: sourceTask = dataFlow.AddPipeLine(SSISMoniker.OLEDB_SPList_SOURCE, Name + " Source"); break; default: throw new Exception("Feature not implemented yet"); } InstanceSource = sourceTask.InitializeTask(); if (Sourcetype != SourceType.TableStorage && Sourcetype != SourceType.SPList) { sourceTask.SetConnection(conMgrSource); } switch (Sourcetype) { case SourceType.SELECTSQL: InstanceSource.SetSQLSource(SourceName, SQLStatementASVariable); break; case SourceType.Table: InstanceSource.SetTableSource(SourceName); break; case SourceType.Excel: InstanceSource.SetTableSource(SourceName); break; case SourceType.FlatFile: break; case SourceType.TableStorage: InstanceSource.SetTableStorageSource(SourceName, ConnectionString); break; case SourceType.SPList: InstanceSource.SetSharePointListSource(SourceName, ConnectionString); break; default: throw new Exception("Feature not implemented yet"); } InstanceSource.ConnectAndReinitializeMetaData(Name); return(dataFlow); }
protected abstract void AfterVisit(InstanceSource source, State state);
protected abstract bool ShouldVisitAfterUpdateState(InstanceSource source, State state);
protected virtual void UpdateState(InstanceSource source, ref State state) { state.InstanceSourcesScope = state.InstanceSourcesScope.Enter(source); }