private static IEnumerable <ChildReference> GetAllReferencedClassesFromClassOrStruct(object current, IEnumerable <FieldInfo> fields, object parent, string currentPath) { foreach (FieldInfo field in fields) { if (!field.FieldType.IsPrimitive) { object referenced = field.GetValue(current); if (referenced != null) { using (IEnumerator <ChildReference> enumerator2 = DistillChildReferencesFromObject(referenced, parent, currentPath + field.Name).GetEnumerator()) { if (enumerator2.MoveNext()) { ChildReference child2 = enumerator2.Current; yield return(child2); /*Error: Unable to find new state assignment for yield return*/; } } } } } if (current != null && current is ICollection) { foundCollections.Add(new WeakReference(current)); IEnumerator enumerator3 = (current as IEnumerable).GetEnumerator(); try { while (enumerator3.MoveNext()) { object entry = enumerator3.Current; if (entry != null && !entry.GetType().IsPrimitive) { using (IEnumerator <ChildReference> enumerator4 = DistillChildReferencesFromObject(entry, parent, currentPath + "[]").GetEnumerator()) { if (enumerator4.MoveNext()) { ChildReference child = enumerator4.Current; yield return(child); /*Error: Unable to find new state assignment for yield return*/; } } } } } finally { IDisposable disposable; IDisposable disposable2 = disposable = (enumerator3 as IDisposable); if (disposable != null) { disposable2.Dispose(); } } } yield break; IL_02f3: /*Error near IL_02f4: Unexpected return in MoveNext()*/; }
private static IEnumerable <ChildReference> DistillChildReferencesFromObject(object current, object parent, string currentPath) { Type type = current.GetType(); if (type.IsClass) { yield return(new ChildReference { child = current, path = currentPath }); /*Error: Unable to find new state assignment for yield return*/; } if (!type.IsPrimitive) { if (!type.IsValueType) { throw new NotImplementedException(); } using (IEnumerator <ChildReference> enumerator = GetAllReferencedClassesFromClassOrStruct(currentPath: currentPath + ".", current: current, fields: GetFieldsFromHierarchy(type, BindingFlags.Instance), parent: parent).GetEnumerator()) { if (enumerator.MoveNext()) { ChildReference childReference = enumerator.Current; yield return(childReference); /*Error: Unable to find new state assignment for yield return*/; } } } yield break; IL_017e: /*Error near IL_017f: Unexpected return in MoveNext()*/; }
/// <summary> /// Inserts a file into a folder. /// Documentation https://developers.google.com/drive/v2/reference/children/insert /// Generation Note: This does not always build corectly. Google needs to standardise things I need to figuer out which ones are wrong. /// </summary> /// <param name="service">Authenticated drive service.</param> /// <param name="folderId">The ID of the folder.</param> /// <param name="body">A valid drive v2 body.</param> /// <returns>ChildReferenceResponse</returns> public static ChildReference Insert(driveService service, string folderId, ChildReference body) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } if (body == null) { throw new ArgumentNullException("body"); } if (folderId == null) { throw new ArgumentNullException(folderId); } // Make the request. return(service.Children.Insert(body, folderId).Execute()); } catch (Exception ex) { throw new Exception("Request Children.Insert failed.", ex); } }
/// <summary> /// Inserts a file into a folder. /// Documentation https://developers.google.com/drive/v2/reference/children/insert /// Generation Note: This does not always build corectly. Google needs to standardise things I need to figuer out which ones are wrong. /// </summary> /// <param name="service">Authenticated Drive service.</param> /// <param name="folderId">The ID of the folder.</param> /// <param name="body">A valid Drive v2 body.</param> /// <param name="optional">Optional paramaters.</param> /// <returns>ChildReferenceResponse</returns> public static ChildReference Insert(DriveService service, string folderId, ChildReference body, ChildrenInsertOptionalParms optional = null) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } if (body == null) { throw new ArgumentNullException("body"); } if (folderId == null) { throw new ArgumentNullException(folderId); } // Building the initial request. var request = service.Children.Insert(body, folderId); // Applying optional parameters to the request. request = (ChildrenResource.InsertRequest)SampleHelpers.ApplyOptionalParms(request, optional); // Requesting data. return(request.Execute()); } catch (Exception ex) { throw new Exception("Request Children.Insert failed.", ex); } }
/// <summary> /// Base constructor. /// </summary> /// <param name="thisChild"></param> public DriveFileVM(ChildReference thisChild, DriveService driveService) { OpenSheetUrl = new RelayCommand(OpenSheetUrlMethod); // Get more information about the file using the child Id try { _file = driveService.Files.Get(thisChild.Id).Execute(); } catch (Exception) { _file = null; } }
private static void AccumulateReferences(object obj, Dictionary <object, ReferenceData> references, HashSet <object> seen, Queue <object> toProcess) { ReferenceData value = null; if (!references.TryGetValue(obj, out value)) { value = (references[obj] = new ReferenceData()); } foreach (ChildReference item in GetAllReferencedClassesFromClassOrStruct(obj, GetFieldsFromHierarchy(obj.GetType(), BindingFlags.Instance), obj, string.Empty)) { ChildReference current = item; if (!current.child.GetType().IsClass) { throw new ApplicationException(); } ReferenceData value2 = null; if (!references.TryGetValue(current.child, out value2)) { value2 = new ReferenceData(); references[current.child] = value2; } value2.referredBy.Add(new ReferenceData.Link { target = obj, targetRef = value, path = current.path }); value.refers.Add(new ReferenceData.Link { target = current.child, targetRef = value2, path = current.path }); if (!seen.Contains(current.child)) { seen.Add(current.child); toProcess.Enqueue(current.child); } } }
private static void AccumulateStaticMembers(Type type, Dictionary <object, ReferenceData> references, HashSet <object> seen, Queue <object> toProcess) { foreach (ChildReference item in GetAllReferencedClassesFromClassOrStruct(null, GetFields(type, BindingFlags.Static), null, type.ToString() + ".")) { ChildReference current = item; if (!current.child.GetType().IsClass) { throw new ApplicationException(); } ReferenceData value = null; if (!references.TryGetValue(current.child, out value)) { value = new ReferenceData(); value.path = current.path; value.pathCost = 0; references[current.child] = value; } if (!seen.Contains(current.child)) { seen.Add(current.child); toProcess.Enqueue(current.child); } } }